LCL in dylib crashes host application when library unloaded.
Original Reporter info from Mantis: ludob
-
Reporter name: Ludo Brands
Original Reporter info from Mantis: ludob
- Reporter name: Ludo Brands
Description:
Created a dynamic library that includes the LCL. The library displays a modal form for configuration purposes. This all works fine.But when the library is unloaded and when I select another application (pushing the current app to the background), the host application (ODBC Administrator in my case) crashes with a KERN_INVALID_ADRESSS. The back trace in the crash report shows a call to an invalid address from com.apple.HIToolbox SendEventToTargetInternal(OpaqueEventRef*,..).
Running the application in gdb, I found out that the crash address corresponds to TCarbonWidgetSet.CarbonApp_Deactivated in carbonobject.inc. I conclude that the application still tries to send events to the library although the library is unloaded.
Looking at the sources, it appears that the CarbonApp_Deactivated event handler is installed in TCarbonWidgetSet.RegisterEvents, but is never removed. That works fine when the LCL is part of the application since stopping the application removes the event target all together. For LCL in a library, if I understand this correctly, the event target is the host application and the event handlers installed by LCL remain in the event chain even when the library is unloaded.
Additional information:
OSX 10.5.7
fpc 2.5.1 17360
lazarus svn 30416
Mantis conversion info:
- Mantis ID: 19253
- Version: 0.9.31 (SVN)
- Fixed in version: 0.9.31 (SVN)
- Fixed in revision: 32931 (#69140ad2)
- Target version: 0.99.0