[Boost-bugs] [Boost C++ Libraries] #5311: io_service::post/dispatch, io_service::stop, deadline_timer crashes

Subject: [Boost-bugs] [Boost C++ Libraries] #5311: io_service::post/dispatch, io_service::stop, deadline_timer crashes
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-03-15 20:44:43


#5311: io_service::post/dispatch, io_service::stop, deadline_timer crashes
---------------------------------------------------------------------------+
 Reporter: nfries88@… | Owner: chris_kohlhoff
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: asio
  Version: Boost 1.46.0 | Severity: Problem
 Keywords: asio, io_service, post, dispatch, stop, deadline_timer, crash |
---------------------------------------------------------------------------+
 I've used programs using boost::asio before, but never used it directly
 myself. I made a test program using boost::asio that models communications
 from a synchronous TCP server to an asynchronous TCP client.

 <Long version>
 The program launches one thread for the server, which creates an acceptor
 and calls async_accept; then runs the io_service. Upon accepting a new
 connection with success, it immediately begins an async read on the new
 connection and another async_accept.
 On the original thread, I create a TCP socket (using a separate
 io_service), connect it to the server, and send a packet saying "Hello,
 Server".
 When the server thread receives this "Hello, Server" packet, it responds
 with a "Hello, Client" packet and begins another async_read with a newly-
 allocated buffer.
 When the client receives this "Hello, Client" packet, since the test
 program has nothing else to do, I begin cleaning up by calling
 io_service::stop on the server's io_service.
 That crashed. I guessed that maybe it was my fault, so instead I called
 service.post(bind(&io_service::stop, &service));. This crashed, so I tried
 the same with service.dispatch(). Now I was confused, so I tried a third
 time with a deadline_timer that expired after 1 millisecond. This also
 crashes.

 <Short version>
 io_service::post, io_service::dispatch, and io_service::stop are all
 crashing when called from a thread other than the one running the
 io_service. An async_read and async_accept are in progress, but no reading
 or connecting is being done.
 deadline_timer::async_wait() crashes when called from a thread other than
 the one calling io_service::run

 Also, none of these crashes are caught by try{}catch(){}.

 <Compiler and System Information>
 Compiler: TDM-MinGW GCC 4.4.1 32-bit
 Compiler Flags: -Wall -s -O2
 Boost Version: 1.46.0
 System: Windows 7 Home Premium 64-bit
 CPU: AMD Turion II P540 (dual-core, 2.40ghz)

 <Information from the crash pop-up>
 Problem signature:
   Problem Event Name: APPCRASH
   Application Name: nettest.exe
   Application Version: 0.0.0.0
   Application Timestamp: 4d7fc897
   Fault Module Name: nettest.exe
   Fault Module Version: 0.0.0.0
   Fault Module Timestamp: 4d7fc897
   Exception Code: c0000005
   Exception Offset: 0002c702
   OS Version: 6.1.7600.2.0.0.768.3
   Locale ID: 1033
   Additional Information 1: 0a9e
   Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
   Additional Information 3: 0a9e
   Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5311>
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:05 UTC