Jump to content
Sign in to follow this  
wuwuxin

Help on Access Violation

Recommended Posts

I am using Delphi 10.4.2, with latest patches,  on Windows Server 2019.

 

32bit application, running in desktop mode.

 

I am having strange access violation.  It seems FastMM5 (with full debug mode) can not capture it.  MadExcept can not capture it either.  By "can not capture" - I meant - nothing is logged though the logs are enabled.

 

The application is a multi-threaded application, and the access violation seems to happen randomly (i.e., I don't know when exactly it will happen, but usually the access violation takes a couple of hours to show up after the application is started, so I cannot really running the debugger and sit there for a couple of hours)....

 

When the access violation happens,  it disappeared from the desktop, but the access violation is logged by the Windows Event Viewer:

Exception code: 0xc0000005
Fault offset: 0x0003d421

 

"Fault offset: 0x0003d421" seems to be the address somewhere inside  the function

System.SysUtils.CreateInOutError

, as shown in the Figure below.

 

Any advice or suggestions?  @David Heffernan

 

2021-05-25_15-16-52.png

Edited by wuwuxin

Share this post


Link to post

Drilling into SysUtils shows SAccessDenied which is 'File access denied'

so lost of elevation? 

  • Thanks 1

Share this post


Link to post
  • 47 minutes ago, Pat Foley said:

    Drilling into SysUtils shows SAccessDenied which is 'File access denied'

    so lost of elevation? 

    Thank you very much.  The application is running with admin account...

But why it is an access violation? 

 

function CreateInOutError: EInOutError;
type
  TErrorRec = record
    Code: Integer;
    Ident: string;
  end;
const
  ErrorMap: array[0..6] of TErrorRec = (
    (Code: 2; Ident: System.SysConst.SFileNotFound),
    (Code: 3; Ident: System.SysConst.SInvalidUnknownFilename),
    (Code: 4; Ident: System.SysConst.STooManyOpenFiles),
    (Code: 5; Ident: System.SysConst.SAccessDenied),
    (Code: 100; Ident: System.SysConst.SEndOfFile),
    (Code: 101; Ident: System.SysConst.SDiskFull),
    (Code: 106; Ident: System.SysConst.SInvalidInput));
var
  I: Integer;
  InOutRes: Integer;
begin
  I := Low(ErrorMap);
  InOutRes := IOResult;  // resets IOResult to zero
  while (I <= High(ErrorMap)) and (ErrorMap[I].Code <> InOutRes) do Inc(I);
  if I <= High(ErrorMap) then
    Result := EInOutError.Create(ErrorMap[I].Ident) else
    Result := EInOutError.CreateResFmt(@SInOutError, [InOutRes]);
  Result.ErrorCode := InOutRes;
end;

 

Share this post


Link to post

If its not elevation  In the past I seen Error code 5 after the machine is awakened from sleep mode.

Share this post


Link to post
Guest
9 hours ago, wuwuxin said:

But why it is an access violation? 

Intriguing question !, but lets look at it objectively and we will see it is not.

 

That procedure it does what it designed to do, the problem is not there, i think the problem is earlier one step happening in ErrorHandler, here i want to say i am not sure about the latest Delphi versions but in older versions, that ErrorHandler was hated by me very much, because it does list cases of errors and for anything other than these cases then it will be handled as IO error !

 

My suggestion is to look earlier, specifically before the last one in the list you captured GetExceptionObject, you have to see what did happen there and where the source of that exception, also check if an exotic exception raised, also there is a chance that this exception is being raised from an OS API leading to this, in all cases walking the stack further will disclose more information.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×