[fpc-devel] cthreads and fpc.cfg?

Martin Frb lazarus at mfriebe.de
Wed Jul 19 12:33:58 CEST 2023


On 19/07/2023 10:22, Michael Van Canneyt via fpc-devel wrote:
>
>
> The error is logical. What is not logical is that it pops up now.
>
> By all logic, we should have seen this error pop up as early as 2016.
>
> Why it pops up only now is a mystery that we need to solve...

I don't have all the details, but maybe there is something buried in the 
following findings.

The early call to threads happens in

#0  InitCriticalSection (cs=...) at ../inc/thread.inc:229
#1  0x000000000049ae18 in $create () at 
../objpas/sysutils/sysencoding.inc:214
#2  0x00000000004a6749 in $SYSUTILS_$$_init$ () at ../unix/sysutils.pp:1903
#3  0x000000000041fc27 in $fpc_initializeunits () at ../inc/system.inc:1134
#4  0x00000000004039be in $main () at fpcmkcfg/fpcmkcfg.pp:585


sysencoding.inc:214
class constructor TEncoding.Create;
hasn't changed recently... (according to git blame)
class constructor TEncoding.Create;
var
   E: TStandardEncoding;
begin
   for E := Low(FStandardEncodings) to High(FStandardEncodings) do
     FStandardEncodings[E] := nil;
{$ifdef FPC_HAS_FEATURE_THREADING}
   InitCriticalSection(FLock);
{$endif}
end;

I don't know if FPC_HAS_FEATURE_THREADING has changed?

Also
unix/sysutils.pp 1903
hasn't changed recently...

Initialization
   InitExceptions;       { Initialize exceptions. OS independent }
   InitInternational;    { Initialize internationalization settings }
   SysConfigDir:='/etc'; { Initialize system config dir }
   OnBeep:=@SysBeep;
{$ifdef android}
   InitAndroid;
{$endif android}


But the function uses a string
     SysConfigDir:='/etc';

Disassembly show it call "create" before InitExceptions
This code must have been inserted by the compiler...

So some recent change in string handling,  now inserts calls to encoding 
create ?

   0x4a6740 <$SYSUTILS_$$_init$>:    push   %rbp
    0x4a6741 <$SYSUTILS_$$_init$+1>:    mov    %rsp,%rbp
    0x4a6744 <$SYSUTILS_$$_init$+4>:    call   0x49ade0 <$create>
    0x4a6749 <$SYSUTILS_$$_init$+9>:    call   0x4a14a0 <InitExceptions>
    0x4a674e <$SYSUTILS_$$_init$+14>:    call   0x4a56a0 <InitInternational>




More information about the fpc-devel mailing list