mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 12:59:24 +02:00
AThreads: ThreadInfo for the main thread move to a global var to prevent problems with heap manager
This commit is contained in:
parent
ac93ad48e3
commit
0c5256300a
@ -83,6 +83,7 @@ type
|
||||
|
||||
var
|
||||
AThreadManager: TThreadManager;
|
||||
AThreadMainThreadInfo: TThreadInfo;
|
||||
AThreadList: PThreadInfo;
|
||||
AThreadListLen: LongInt;
|
||||
AThreadNum: LongInt;
|
||||
@ -394,7 +395,10 @@ begin
|
||||
SysDebugLn('FPC AThreads: Entering multithreaded mode...');
|
||||
{$endif}
|
||||
p:=PProcess(FindTask(nil));
|
||||
new(threadInfo);
|
||||
{ the main thread info is allocated as a global var, it is the cleanest solution,
|
||||
as it can never really be freed after threading was initialized, due to clashes
|
||||
with threadvar handling in heap managers, etc. }
|
||||
threadInfo:=@AThreadMainThreadInfo;
|
||||
FillChar(threadInfo^,sizeof(TThreadInfo),0);
|
||||
p^.pr_Task.tc_UserData:=threadInfo;
|
||||
threadInfo^.mainThread:=true;
|
||||
|
Loading…
Reference in New Issue
Block a user