BeginThread started in dll started from thread = random crashes
Original Reporter info from Mantis: payl
-
Reporter name: Paul W
Original Reporter info from Mantis: payl
- Reporter name: Paul W
Description:
If you use BeginThread inside FPC dll that is launched from thread itself, you will crash in FPC RTL.
Additional information:
to reproduce:
1.Compile attached source to test.dll
2.Compile & run this: http://pastebin.com/BjpRqjik or inject test.dll into any process you desire (it will also run test.dll from thread)
3.You will usually see 'test' messagebox once or twice, then it will crash inside ntdll.dll (due to uninitialized CriticalSection entering).
Crash happens inside newly created thread, before first line of procedure is executed, in FPC initialization.
Stack:
#0 ntdll!EtwNotificationUnregister at :0 ;inc [eax+14h] => inc [0+14h] => crash
#1 ntdll!EtwNotificationUnregister at :0
#2 SYSTEM_SYSENTERCRITICALSECTION$formal at :0
#3 SYSTEM_ENTERCRITICALSECTION$TRTLCRITICALSECTION at :0
#4 SYSTEM_WAITFREE_FIXED$PMEMCHUNK_FIXED$POSCHUNK at :0
#5 ?? at :0
#6 KERNEL32!AcquireSRWLockExclusive at :0 ;thread begin
#7 ntdll!RtlInsertElementGenericTableAvl at :0
#8 ntdll!RtlInsertElementGenericTableAvl at :0
#9 ?? at :0
Mantis conversion info:
- Mantis ID: 22115
- OS: Windows x86
- OS Build: 7
- Version: 2.6.0
- Monitored by: » payl (Paul W), » Cyrax (Cyrax), » AntonK (Anton Kavalenka)