* Finalize units after printing the runtime error message. Rationale:

* Unit finalization executes arbitrarily large amount of code. Doing it when error occurred can cause
    other errors, overwriting the original error information.
  * Code that prints error message depends on everything and a kitchen sink (most notably, Unicode manager
    and lineinfo unit). Running it after finalizing units can be successful only by coincidence.
  * Last but not least, this sequence (ExitProc -> print RTE -> finalize units) is same as one used in Delphi.

git-svn-id: trunk@29733 -
This commit is contained in:
sergei 2015-02-16 22:05:54 +00:00
parent 9eeef2581b
commit 72315c9bee

View File

@ -398,7 +398,7 @@ end;
{$i gencurr.inc}
function aligntoptr(p : pointer) : pointer;inline;
function RTTIAlign(p : pointer) : pointer;inline;
begin
{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
result:=align(p,sizeof(p));
@ -557,8 +557,6 @@ const
VAR
mt : tMT19937StateArray;
const
mti: longint=MT19937N+1; // mti=MT19937N+1 means mt[] is not initialized
{ Initializing the array with a seed }
@ -973,8 +971,6 @@ Begin
exitProc:=nil;
current_exit();
End;
{ Finalize units }
FinalizeUnits;
{$ifdef FPC_HAS_FEATURE_CONSOLEIO}
{ the embedded system unit itself contains no routines for console i/o
@ -995,6 +991,9 @@ Begin
{$endif EMBEDDED}
{$endif FPC_HAS_FEATURE_CONSOLEIO}
{ Finalize units }
FinalizeUnits;
{$if defined(MSWINDOWS) or defined(OS2)}
{ finally release the heap if possible, especially
important for DLLs.