[fpc-devel] Exception handling failure

Adriaan van Os adriaan at adriaan.biz
Fri Mar 20 22:31:12 CET 2026


Adriaan van Os via fpc-devel wrote:
> 
> I see that fpc source commit 4921be35 
> https://gitlab.com/freepascal.org/fpc/source/-/commit/4921be352392c32c401dd689de50980fdaa7b578 
> adds "some exception related tests that currently fail on 
> aarch64-win64". I see no committed fixes in the history after that.  My 
> 3.3.1 compiler was built from the jan 10 sources (as a more recent 
> revision failed to bootstrap). This 3.3.1 compiler fails a simple 
> exception handling test on macOS, which previous compilers did handle.
> 
> 
> [Mac-mini:~/fpc-test/simple-crashme] administrator% cat crashme2.pas
> 
> {$modeswitch exceptions}
> program crashme2;
> type
>   pinteger = ^integer;
> var
>   p: pinteger;
> begin
>   try
>     p := pinteger( 1234);
>     p^ := 1
>   except
>     writeln
>       ( 'the exception was catched')
>   end
> 
> 
> [Mac-mini:~/fpc-test/simple-crashme] administrator% 
> /usr/local/lib/fpc/3.3.1/ppca64 crashme2.pas
> Free Pascal Compiler version 3.3.1 [2026/01/10] for aarch64
> Copyright (c) 1993-2026 by Florian Klaempfl and others
> Target OS: Darwin for AArch64
> Compiling crashme2.pas
> Assembling (pipe) crashme2.s
> Linking crashme2
> -macosx_version_min has been renamed to -macos_version_min
> 16 lines compiled, 0.4 sec, 180224 bytes code, 98303 bytes data
> 
> [Mac-mini:~/fpc-test/simple-crashme] administrator% ./crashme2
> Runtime error 216 at $0000000104EC36A8
>   $0000000104EC36A8
>   $0000000104EEB4CC
>   $0000000104EC35E0
>   $0000000104EC3638
>   $00000001820C7154
>   $4E35800000000000
> 
> 
> [Mac-mini:~/fpc-test/simple-crashme] administrator% 
> /usr/local/lib/fpc/3.2.4/ppca64 crashme2.pas
> Free Pascal Compiler version 3.2.4-rc1 [2025/10/15] for aarch64
> Copyright (c) 1993-2024 by Florian Klaempfl and others
> Target OS: Darwin for AArch64
> Compiling crashme2.pas
> Assembling crashme2
> Linking crashme2
> ld: warning: -multiply_defined is obsolete
> -macosx_version_min has been renamed to -macos_version_min
> 16 lines compiled, 0.1 sec
> 
> [Mac-mini:~/fpc-test/simple-crashme] administrator% ./crashme2
> the exception was catched
> 
> 
> [Mac-mini:~/fpc-test/simple-crashme] administrator% 
> /usr/local/lib/fpc/3.0.4/ppcx64 crashme2.pas
> Free Pascal Compiler version 3.0.4 [2017/11/26] for x86_64
> Copyright (c) 1993-2017 by Florian Klaempfl and others
> Target OS: Darwin for x86_64
> Compiling crashme2.pas
> Assembling (pipe) crashme2.s
> Linking crashme2
> ld: warning: -multiply_defined is obsolete
> -macosx_version_min has been renamed to -macos_version_min
> ld: warning: support for macOS with 10.5 minimum deployment target is 
> deprecated and will be removed in future release
> ld: warning: building for macOS 10.5 is deprecated
> 16 lines compiled, 0.2 sec
> 
> [Mac-mini:~/fpc-test/simple-crashme] administrator% ./crashme2
> the exception was catched
> 
> 
> [Mac-mini:~] administrator% sw_vers
> ProductName:        macOS
> ProductVersion:        14.7.4
> BuildVersion:        23H420

I found the cause to be in this crazy compiler commit 
https://gitlab.com/freepascal.org/fpc/source/-/work_items/38201which says that "If SysUtils is not 
included, run-time error should be raised regardless from the try..except block."

Regards,

Adriaan van Os



More information about the fpc-devel mailing list