Access Violation in MadExcept32.dll

delphi package - automated exception handling
Post Reply
david_navigator
Posts: 21
Joined: Thu Feb 22, 2018 8:45 pm

Access Violation in MadExcept32.dll

Post by david_navigator »

The following code causes an AV in Madexcept32.dll

I've tried calling MadExcept.StopLeakChecking before this routine, but it makes no difference (turning off leak checking completely lets the code runs fine) .

Any suggestions ?

Code: Select all

    lNoMem := true;
    if File_Stream.Size > high(Integer) then
      lChunkSize := 1024 * 1024 * 1024
    else
      lChunkSize := File_Stream.Size;

    while lNoMem do
    begin
      try
        SetLength(File_Byte, lChunkSize);
        lNoMem := false;
      except
        on EOutOfMemory do
            lChunkSize := lChunkSize div 2;
      end;
   end;
DLL is V 4.0.6.0 dated 8th March 2023

Code: Select all

main thread ($25f8), inner exception level 1:
>> EAccessViolation, Access violation at address 78932EDD in module 'madExcept32.dll'. Write of address 00000000
78932edd +021 madExcept32.dll madExcept                    OnExceptionCleanupStack
788b1fb3 +027 madExcept32.dll madTypes                     MadException.Destroy
0052b32c +008 HireTrackNX.exe System            18378   +1 TObject.Free
00921685 +009 HireTrackNX.exe madExcept                    InterceptFreeExceptObject
0052c962 +016 HireTrackNX.exe System            23693  +14 @DoneExcept
020a0891 +1b1 HireTrackNX.exe DreamHostFileUnit   266  +30 TDreamHostRemoteFileSystem.CopyLocalFiletoRemote
773e87b1 +021 ntdll.dll                                    KiUserExceptionDispatcher
006c42cc +02c HireTrackNX.exe Vcl.Controls      10321   +3 TWinControl.MainWndProc
006c42e7 +047 HireTrackNX.exe Vcl.Controls      10324   +6 TWinControl.MainWndProc
788fa80d +379 madExcept32.dll madExcept                    IsValidObject2
78933441 +0bd madExcept32.dll madExcept                    SetLastExceptionHelper
789334a6 +05a madExcept32.dll madExcept                    MyRaiseExceptProc
788a4fa2 +016 madExcept32.dll System              380   +0 ErrorAt
788a4fe6 +00e madExcept32.dll System              380   +0 Error
78949280 +154 madExcept32.dll madExceptDbg       1772  +53 GetMemCallback
04445d97 +1f7 HireTrackNX.exe HelpSupportMainU   1181  +13 THelpSupportForm.UploadToDreamObjects
04444958 +028 HireTrackNX.exe HelpSupportMainU    842   +1 THelpSupportForm.UploadtoSupport
04444ce4 +348 HireTrackNX.exe HelpSupportMainU    949  +40 THelpSupportForm.CompressAndUpload
04444277 +317 HireTrackNX.exe HelpSupportMainU    684  +48 THelpSupportForm.SendtoSupportBtnClick
madshi
Site Admin
Posts: 10766
Joined: Sun Mar 21, 2004 5:25 pm

Re: Access Violation in MadExcept32.dll

Post by madshi »

If I understand your code correctly, you're basically allocating a 1GB memory block via SetLength? That's very non-recommended to do. To be honest, I'm not fully sure why madExcept32.dll crashes, but generally, doing leak checking in 32bit adds a lot of RAM consumption on top of everything else, so there's already a certain risk that doing leak checking in 32bit might run out of RAM. If you add such big allocations, that increases the risk exponentially. I think this crash *may* be due to running out of RAM, but I'm not sure right now. I'm extremely busy atm, so I don't really have time to look into this right now.
david_navigator
Posts: 21
Joined: Thu Feb 22, 2018 8:45 pm

Re: Access Violation in MadExcept32.dll

Post by david_navigator »

Hi
Actually in this case only 160 MB

lChunkSize := File_Stream.Size;

The 1GB limit is for stupid sized files.

I'll try and reduce the size when leak checking to see if that addresses the issue, assuming there's no way to turn off leak checking for a specific method ?

David
david_navigator
Posts: 21
Joined: Thu Feb 22, 2018 8:45 pm

Re: Access Violation in MadExcept32.dll

Post by david_navigator »

FYI

Changing the initial chunk size to 25 MB cured the AV.

David
Post Reply