[fpc-devel] threads vs widestringmanager / crash

Martin fpc at mfriebe.de
Sat Jul 7 14:00:11 CEST 2018


fpc 3.0.4
Win 10 / 32bit

Lazarus trunk, but that may not be relevant.
This is the first time I am seeing this, and I am therefore not sure I 
will be able to reproduce, since it seems a race condition.

This appears to happen during unit initialization.

Something must have started a thread, before widestring manager got 
initialized.
In other word, some unit (used in such order that it's initialization 
runs before unit system initialization) has started a thread.

This thread crashes, if it is fast enough, because in the threads init 
it will access widestringmanager.

Is this a bug in fpc?
Or is this wrong of the calling code (eg starting threads during unit 
initialization).

In the latter case, is it documented?

The trace from the thread:
#0 ?? at :0
#1 OPENSTDIO({}, 55217, 168) at ..\inc\text.inc:2670
#2 SYSINITSTDIO at ..\win\syswin.inc:520
#3 INITTHREAD(16777216) at ..\inc\thread.inc:59
#4 EXEC_TLS_CALLBACK(0x400000, 2, 0x0) at ..\win\systlsdir.inc:90
#5 ntdll!WinSqmSetDWORD64 at :0
#6 ?? at :0
#7 ntdll!RtlDeactivateActivationContextUnsafeFast at :0
#8 ntdll!RtlCaptureStackContext at :0
#9 ntdll!LdrShutdownThread at :0
#10 ntdll!LdrInitializeThunk at :0
#11 ntdll!LdrInitializeThunk at :0
#12 ntdll!LdrInitializeThunk at :0
#13 ?? at :0

The main thread sit right before widestring initialization.
#0 INITUNICODESTRINGMANAGER at ..\inc\ustrings.inc:2311
#1 SYSTEM_$$_init$ at :674
#2 fpc_initializeunits at ..\inc\system.inc:886
#3 main at lazarus.pp:87




More information about the fpc-devel mailing list