[fpc-pascal] Unhandled exception from library crashes host exe

Antonio Fortuny a.fortuny at sitasoftware.lu
Wed Jun 27 16:11:35 CEST 2012

Le 27/06/2012 15:58, kyan a écrit :
> I am sure that this has been asked before but I couldn't find an answer.
> I am in the process of porting a large application consisting of an
> exe and many dlls from Delphi7 to FPC 2.7.1/Lazarus for Windows/WinCE
> with hopes of being able to finally port it to Linux. I have managed
> to overcome all obstacles but this seems like a brick wall: An
> exception raised from a dll that is not handled by the dll's code will
> crash the exe, bypassing any try/finally/except handlers around the
> call into the dll that raised it. This is of course a complete
> showstopper because the API and code of the dlls is way too massive to
> re-engineer so that it does not let exceptions bubble up to the exe.
Got the same with UDFs for FIrebird. Read two Firebird bugs:
they appear to be intimately related.
> In Delphi without packages the aforementioned situation can be handled
> reasonably well because despite the fact that operators "is" and "as"
> won't work on the dll's Exception object (its class pointer points
> inside the dll's Exception class and not the exe's Exception class) at
> least the exception handlers work so one can display an error message
> and keep the main application loop running. It is solved perfectly if
> one builds all executables with runtime packages so that there is only
> one Exception class for the exe and all dlls. But in FPC there are no
> "runtime packages" in the Delphi sense, therefore there doesn't seem
> to be a solution to this.
> Can someone suggest a solution, even if I have to manually apply a
> patch to FPC and build it myself? Because if there isn't one I will
> have to scrap the whole project.
> Thank you in advance.
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

More information about the fpc-pascal mailing list