[Boost-bugs] [Boost C++ Libraries] #6654: deadline_timer may makes dll can't be freed

Subject: [Boost-bugs] [Boost C++ Libraries] #6654: deadline_timer may makes dll can't be freed
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-03-06 08:54:33

#6654: deadline_timer may makes dll can't be freed
 Reporter: weiyuemin@… | Owner: chris_kohlhoff
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: asio
  Version: Boost 1.49.0 | Severity: Problem
 Keywords: deadline_timer block |
 When I use boost::asio::deadline_timer in a dll, {{{FreeLibrary}}} will be
 blocked. When I commented the deadline_timer, things become ok.

 I compile my program on Visual Studio 2010(without sp), and Win Xp sp3.
 dll was built as Debug configuration, using /MDd

 below is my code in main():
         HMODULE hmod2 = LoadLibraryA("tDll2.dll");
         printf("tDll2.dll loaded\n");

         for (;;)
                 char cmd[100];
                 scanf("%s", cmd);

                 if (strcmp(cmd, "init") == 0)
                         void_func _init = (void_func)GetProcAddress(hmod2,
                         printf("init ok\n");
                 else if (strcmp(cmd, "uninit") == 0)
                         void_func _uninit =
 (void_func)GetProcAddress(hmod2, "uninit");
                         printf("uninit ok\n");
                 else if (strcmp(cmd, "exit") == 0)
                         printf("tFreeLib.dll free\n");

 code of tDll2.cpp in tDll2.dll

 boost::asio::io_service client_ioservice;

 boost::asio::io_service::work* client_ioservice_virtual_work;

 boost::thread* th;

 void run()
         boost::asio::deadline_timer timer(client_ioservice);

         boost::system::error_code error;


         if (error)
                 printf("error: %d\n", error.value());

         delete th;


 TDLL2_API void init(void)
         client_ioservice_virtual_work = new
         th = new boost::thread(run);

 TDLL2_API void uninit(void)
         delete client_ioservice_virtual_work;

 this statement {{{printf("finish\n"); }}}is successfully executed, the
 {{{DllMain}}} is also successfully returned, but {{{FreeLibrary(hmod2);}}}

 When I commented this line:
   boost::asio::deadline_timer timer(client_ioservice);
 things become ok.

Ticket URL: <https://svn.boost.org/trac/boost/ticket/6654>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC