[fpc-devel] threads vs widestringmanager / crash

Ondrej Pokorny lazarus at kluug.net
Mon Dec 19 08:29:55 CET 2022


On 19.12.2022 07:42, Sven Barth via fpc-devel wrote:
> The RTL assumes that it does not have to deal with threads during the 
> initialization of the System unit. So even if the symptom of the crash 
> is fixed in that location it isn't said that something else might 
> crash or that in the future code might be added that crashes...

Is it possible to acknowledge that the current RTLs assumption is wrong 
and it has to deal with threads during the System initialization? 
(Because obviously the assumption is wrong, otherwise there was no crash.)

That means not to fix the symptom with checking 
"Assigned(WideStringManager.GetStandardCodePageProc)" but acknowledge 
that the OS can start a thread before System initialization is done and 
create a mechanism to postpone thread initialization until System is 
fully initialized.

Something like:

     procedure InitThread(stklen:SizeUInt);
       begin
// new code begin
         while not SystemInitialized do
           Sleep(10);
// new code end
{$ifndef FPUNONE}
         SysResetFPU;
{$endif}

Ondrej



More information about the fpc-devel mailing list