Uploaded image for project: 'Qpid'
  1. Qpid
  2. QPID-4330

windows clients hang or fault on exit (static destructors)


    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.16, 0.18
    • Fix Version/s: 0.19
    • Component/s: C++ Client
    • Labels:
    • Environment:



      Windows clients occasionally fail to terminate cleanly after exit() or return from main(). I have examined a large number of stack traces, mostly gibberish presumably from rogue memory writes some time in the past. Two refreshingly clear traces showed failure when direct or indirect threading calls were made from inside a static destructor: ~IOThread and ~WinSockSetup.

      If a DLL (shared object) is winding up due to the library being unloaded (FreeLibrary), the DLL code has an obligation to clean up resources that could leak, and since the process hasn't exited, existing threads live on and threading primitives are trustworthy. In this case the Windows library may (and should) follow the Linux clean up logic in its static destructors.

      If the DLL is winding up due to exit() (or return from main()), it is undefined how quickly other threads will be forcefully terminated. Locks may be held indefinitely or falsely released (changed in the Vista time frame). In this case, any fancy footwork is dangerous. The best course of action is to let the OS clean up things it would anyway, i.e. do nothing if possible.




            • Assignee:
              cliffjansen Cliff Jansen
              cliffjansen Cliff Jansen
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: