mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 09:39:09 +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
|
var
|
||||||
AThreadManager: TThreadManager;
|
AThreadManager: TThreadManager;
|
||||||
|
AThreadMainThreadInfo: TThreadInfo;
|
||||||
AThreadList: PThreadInfo;
|
AThreadList: PThreadInfo;
|
||||||
AThreadListLen: LongInt;
|
AThreadListLen: LongInt;
|
||||||
AThreadNum: LongInt;
|
AThreadNum: LongInt;
|
||||||
@ -394,7 +395,10 @@ begin
|
|||||||
SysDebugLn('FPC AThreads: Entering multithreaded mode...');
|
SysDebugLn('FPC AThreads: Entering multithreaded mode...');
|
||||||
{$endif}
|
{$endif}
|
||||||
p:=PProcess(FindTask(nil));
|
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);
|
FillChar(threadInfo^,sizeof(TThreadInfo),0);
|
||||||
p^.pr_Task.tc_UserData:=threadInfo;
|
p^.pr_Task.tc_UserData:=threadInfo;
|
||||||
threadInfo^.mainThread:=true;
|
threadInfo^.mainThread:=true;
|
||||||
|
Loading…
Reference in New Issue
Block a user