Opened 10 years ago

Closed 10 years ago

#7162 closed Bugs (fixed)

socket streams crash with C++11 enabled; tie(this) no longer legal

Reported by: andrew.c.morrow@… Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

The boost::asio sockets streams classes derive from std::basic_iostream, and then call tie(this)] in the basic_socket_iostream constructor.

In C++11 this is no longer legal (I tried providing a link here, but trac wouldn't let me). The issue is explained here: cplusplus.github.com/LWG/lwg-defects.html#835

Some standard libraries (like libc++) already implement this behavior, and so attempts to use the ASIO socket streams classes cause infinite recursion leading to eventual stack exhaustion and a crash.

I found this issue in boost 1.50.0, but it appears on the boost trunk svn as well so I have filled the ticket against trunk.

Change History (2)

comment:1 by chris_kohlhoff, 10 years ago

(In [79710]) Instead of using tie(), set the ios_base::unitbuf flag to force the stream to be flushed after every insertion. Refs #7162

comment:2 by chris_kohlhoff, 10 years ago

Resolution: fixed
Status: newclosed

(In [79712]) Merge from trunk:

  • Instead of using tie(), set the ios_base::unitbuf flag to force the stream to be flushed after every insertion. Fixes #7162
Note: See TracTickets for help on using tickets.