Page 1 of 1

Access violation closing application ONLY in Delphi 10.4

Posted: Wed Jun 30, 2021 5:00 pm
by Mikas
Hi,

I've recently upgraded my project to Delphi 10.4.
Previous to this upgrade everyting was working fine.

Now, i get this crash report when closing the application:

compiled with : Delphi 10.4 Sydney
madExcept version : 5.1.1
callstack crc : $fd7ea850, $9451dc5e, $2a7f24a9
exception number : 1
exception class : EAccessViolation
exception message : Access violation at address 0041268C in module 'ZSRest.exe'. Read of address 583D173C.

main thread ($2948):
0041268c +010 ZSRest.exe System 204 +0 @IntfClear
0040f2a5 +17d ZSRest.exe System 204 +0 @FinalizeArray
0040f020 +10c ZSRest.exe System 204 +0 @FinalizeRecord
0040b034 +01c ZSRest.exe System 204 +0 TObject.CleanupInstance
0040ae5d +005 ZSRest.exe System 204 +0 TObject.FreeInstance
004bdfe5 +019 ZSRest.exe madExcept 17410 +3 InterceptClassDestroy
0067a320 +0c0 ZSRest.exe Vcl.Graphics 10669 +14 TWICImage.Destroy
0040af5c +008 ZSRest.exe System 204 +0 TObject.Free
0054e7d4 +03c ZSRest.exe System.Classes TCollection.Clear
0054e662 +01a ZSRest.exe System.Classes TCollection.Destroy
0040af5c +008 ZSRest.exe System 204 +0 TObject.Free
00a58a4a +00e ZSRest.exe Vcl.ImageCollection TImageCollectionItem.Destroy
0040af5c +008 ZSRest.exe System 204 +0 TObject.Free
0054e7d4 +03c ZSRest.exe System.Classes TCollection.Clear
0054e662 +01a ZSRest.exe System.Classes TCollection.Destroy
0040af5c +008 ZSRest.exe System 204 +0 TObject.Free
00a58cda +00e ZSRest.exe Vcl.ImageCollection TImageCollection.Destroy
0040af5c +008 ZSRest.exe System 204 +0 TObject.Free
00a723b9 +015 ZSRest.exe Vcl.DBGrids TCustomDBGrid.Destroy@
0040c7ea +03e ZSRest.exe System 204 +0 FinalizeUnits
004bd5c8 +054 ZSRest.exe madExcept 17114 +36 InterceptFinalizeUnits
004bd5d8 +000 ZSRest.exe madExcept 17128 +0 InterceptHalt0FinalizeUnits
0040cc3c +0ac ZSRest.exe System 204 +0 @Halt0
031ec55e +092 ZSRest.exe ZSRest 1203 +14 initialization
75d8fa27 +017 KERNEL32.DLL BaseThreadInitThunk

I was able to put a breakpoint in Vcl.Graphics on TWICImage.Destroy.
However madExcept is actually triggered before that, i don't know where, but this is what ends up on the bugreport.

Any help would be much appreciated.

Thanks

Re: Access violation closing application ONLY in Delphi 10.4

Posted: Wed Jun 30, 2021 5:05 pm
by madshi
It would seem that the crash occurs while Delphi is working its way through the finalization sections of all the units. For some reason there seems to be a TCustomDBGrid which is destroyed. That is if the callstack is reliable, it not always is.

If I may suggest, I'd recompile the project with debug DCUs enabled, so you can set breakpoints on the RTL/VCL units, then set a breakpoint on System.FinalizeUnits and then walk your way through all the finalization sections from there step by step. This may be painful because there may be a lot of them (depending on how many units you have in your project), but this might just be the best course of action. Once you've figured out which finalization section it is, which causes the crash, hopefully you'll be able to narrow it down from there.

Re: Access violation closing application ONLY in Delphi 10.4

Posted: Fri Jul 02, 2021 8:05 am
by Mikas
Thank you for the quick response.

I will try your suggestion.
Something i forgot to mention is that if i disable madExcept, no exception is thrown even with the debugger attached.

But i will try what your solution.

Thank you.

Re: Access violation closing application ONLY in Delphi 10.4

Posted: Fri Jul 02, 2021 9:04 am
by madshi
No exception being thrown without madExcept doesn't mean a lot. The RTL sometimes silently "swallows" shutdown exceptions, or madExcept may introduce some timing differences which can result in crashes which otherwise would not occur (without being madExcept's fault). But of course it's not impossible that there's a bug in madExcept. It's just pretty rare, these days, because the madExcept core has been stable for years without barely any stability problems reported.

Re: Access violation closing application ONLY in Delphi 10.4

Posted: Fri Jul 02, 2021 10:36 am
by Mikas
Hey again,

Thanks for the tip. It's something related with CEF4Delphi.
It is fixed.

Thank you.