CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2005
    Posts
    78

    FreeLibrary hanging forever

    I'm using a dll that doesn't belong to me and i don't have the source code
    of the dll.

    Everything works fine with that dll except when I call FreeLibrary when i try
    to exit my app, it hangs there forever and my app get stuck in the memory....

    Is there a way to skip the unload of the dll ? I try to skip the call "FreeLibrary"
    but it won't help, the system seems still try to unload the dll.

    THanks for any help on this.

  2. #2
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: FreeLibrary hanging forever

    How bout a sample app which just does a LoadLibrary and FreeLibrary ? Do u see the same observation ?

    Note: When process exits,all libraries will be unloaded, no matter what.

  3. #3
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: FreeLibrary hanging forever

    Well....maybe the dll runs into a deadlock or similar while cleaning up...however, without the source not that easily traceable...

  4. #4
    Join Date
    Feb 2005
    Posts
    78

    Re: FreeLibrary hanging forever

    Thanks for the replies...
    That is my real problem now, because i don't have the source code of the dll,
    i only have the dll binary itself......The sample also hangs...

    Is there any way for my app to exit without waiting for the dll unloading ?

  5. #5
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537

    Re: FreeLibrary hanging forever

    Unload the DLL's you care about. Clean up your resources then call TerminateProcess(...) on yourself.

    You should at least try and see what is happening by using the symbol server and stepping into the disassembly Look at the exports of the dll maybe you need to call some de-init function [for whatever reason]. If you can contact the developer(s) of the dll.

    symbol server:
    http://msdn.microsoft.com/library/de...mbolserver.asp

  6. #6
    Join Date
    Feb 2005
    Posts
    78

    Re: FreeLibrary hanging forever

    Yes, terminateprocess works.....but i don't know if it will cause any problem.

    At least my app is terminated right away.

    THank you very much for the help.

  7. #7
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537

    Re: FreeLibrary hanging forever

    Quote Originally Posted by tim24
    Yes, terminateprocess works.....but i don't know if it will cause any problem.

    At least my app is terminated right away.

    THank you very much for the help.
    That is why I said to clean up any dlls you need to by explicitly calling FreeLibrary(...) on them [however many times you need] and to clean up any resources that you may have. TerminateProcess(...) bypasses notifying Dll's that the process is exiting.

    I woud not leave this as it is [but you asked]. I would seek an answer as to why the Dll is blocking.

    TerminateProcess

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured