Ignore:
Timestamp:
Jul 5, 2011, 7:44:49 PM (14 years ago)
Author:
dmik
Message:

kernel32: Do not unwind Win32 exception handlers from DLL_InitTerm() as there is no guarantee that the stack frames are alive.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/initkernel32.cpp

    r21654 r21661  
    7373}
    7474
    75 // borrowed from ntddk.h
    76 extern "C"
    77 void WIN32API RtlUnwind(
    78         LPVOID,
    79         LPVOID,
    80         LPVOID,DWORD);
    81 
    8275extern PFN pfnImSetMsgQueueProperty;
    8376
     
    318311    dprintf(("kernel32 exit %d", ulReason));
    319312
    320     TEB *teb = GetThreadTEB();
    321 
    322     if (teb)
    323     {
    324         // make sure the Win32 exception stack (if there is still any) is unwound
    325         // before we destroy internal structures including the Win32 TEB
    326         RtlUnwind(NULL, 0, 0, 0);
    327     }
    328 
    329313    if( IsDBCSEnv() && imHandle )
    330314        DosFreeModule( imHandle );
     
    340324    OSLibLVMExit();
    341325
     326    // Note: unwinding win32 exceptions before destroying TEB like we do in
     327    // ExitThread()/ExitProcess() is impossible here since the stack is already
     328    // vanished at this point. In cases where process termination is not coming
     329    // from ExitThread()/ExitProcess(), unwinding is to be done by
     330    // OS2ExceptionHandler2ndLevel() in responce to the normal unwind procedure.
     331
     332    TEB *teb = GetThreadTEB();
    342333    if(teb) DestroyTEB(teb);
     334
    343335    DestroySharedHeap();
    344336    DestroyCodeHeap();
Note: See TracChangeset for help on using the changeset viewer.