Exceptions during the initialization of units are 'eaten' (with SEH-based exeptions)
Original Reporter info from Mantis: Joost
-
Reporter name: Joost van der Sluis
Original Reporter info from Mantis: Joost
- Reporter name: Joost van der Sluis
Description:
When an exception is raised during/in the initialization-section/phase of a unit within a library, the application is killed immediately. The exception is not shown or handled.
This only happens when SEH-excaptions are enabled, on win64 and win32.
Steps to reproduce:
When the library below is used in an application. the application is killed immediately (The exception anr/or the stacktrace are not shown)
{$mode objfpc}
library tw9999a;
uses
tw9999b;
procedure library_procedure;
begin
writeln('Not ok');
end;
exports library_procedure;
begin
end.
{$mode objfpc}
unit tw9999b;
interface
uses
sysutils;
implementation
initialization
raise Exception.Create('One should see this exception.');
end.
Additional information:
My guess is that one of the exception-frames is missing, so that the call to kernel32.dll's RaiseException ends up in a call to RaiseFailFastException. The backtrace looks as follows:
gdb: unknown target exception 0xe0465043 at 0x75fe35d2
Program received signal ?, Unknown signal.
0x75fe35d2 in RaiseFailFastException () from C:\WINDOWS\SysWOW64\KernelBase.dll
(gdb) bt
#0 0x75fe35d2 in RaiseFailFastException () from C:\WINDOWS\SysWOW64\KernelBase.dll
#1 0x1000fa7f in fpc_raiseexception () from C:\tmp\SEHTests\tw9999a.dll
#2 0x10010465 in TW9999B_$$_init$ () at tw9999b.pp:13
#3 0x10009d0a in fpc_initializeunits () from C:\tmp\SEHTests\tw9999a.dll
#4 0x10009d46 in fpc_libinitializeunits () from C:\tmp\SEHTests\tw9999a.dll
#5 0x10001628 in P$TW9999A_$$_main () at tw9999a.pp:16
Mantis conversion info:
- Mantis ID: 36544
- OS: Windows
- Platform: x86
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 43901 (#7a0a1d9f)
- Monitored by: » @CuriousKit (J. Gareth Moreton)
- Target version: 3.2.0