Boost C++ Libraries: Ticket #8337: The internal representation of "std::string(this->code()->message())" escapes, but is destroyed when it exits scope. https://svn.boost.org/trac10/ticket/8337 <p> Coverity static analysis reported the following problem: </p> <pre class="wiki">class BOOST_SYMBOL_VISIBLE future_error : public std::logic_error { system::error_code ec_; public: future_error(system::error_code ec) : logic_error(ec.message()), ec_(ec) { } const system::error_code&amp; code() const BOOST_NOEXCEPT { return ec_; } const char* what() const BOOST_THREAD_NOEXCEPT_OR_THROW { CID 10932 (#2 of 2): Wrapper object use after free (WRAPPER_ESCAPE)1. escape: The internal representation of "std::string(this-&gt;code()-&gt;message())" escapes, but is destroyed when it exits scope. return code().message().c_str(); } }; </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8337 Trac 1.4.3 viboes Thu, 28 Mar 2013 23:57:15 GMT owner, status, description changed https://svn.boost.org/trac10/ticket/8337#comment:1 https://svn.boost.org/trac10/ticket/8337#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>description</strong> modified (<a href="/trac10/ticket/8337?action=diff&amp;version=1">diff</a>) </li> </ul> <p> Could you clarify what is the bug? </p> Ticket Steven Watanabe Fri, 29 Mar 2013 04:03:38 GMT <link>https://svn.boost.org/trac10/ticket/8337#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8337#comment:2</guid> <description> <p> boost::system::error_code::message returns a temporary string, which is destroyed when the function returns. The pointer returned by what() is dangling. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 30 Mar 2013 08:54:13 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8337#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8337#comment:3</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/8337#comment:2" title="Comment 2">steven_watanabe</a>: </p> <blockquote class="citation"> <p> boost::system::error_code::message returns a temporary string, which is destroyed when the function returns. The pointer returned by what() is dangling. </p> </blockquote> <p> Oh I see. Please could you try just removing the overriding of the what() function? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 30 Mar 2013 14:37:58 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/8337#comment:4 https://svn.boost.org/trac10/ticket/8337#comment:4 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.54.0</span> </li> </ul> <p> Committed revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/83649" title="Thread: remove what() function from future_error to take care of #8337.">[83649]</a>. </p> Ticket viboes Sun, 31 Mar 2013 10:56:54 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/8337#comment:5 https://svn.boost.org/trac10/ticket/8337#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/83660" title="Thread: merge from trunk 1.54. Fix #8027,#8323,#8337.">[83660]</a>) Thread: merge from trunk 1.54. Fix <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8027" title="#8027: Bugs: thread library fails to compile with Visual Studio 2003 (closed: fixed)">#8027</a>,<a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8323" title="#8323: Bugs: boost::thread::try_join_for/try_join_until may block indefinitely due ... (closed: fixed)">#8323</a>,<a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8337" title="#8337: Bugs: The internal representation of &#34;std::string(this-&gt;code()-&gt;message())&#34; ... (closed: fixed)">#8337</a>. </p> Ticket