[Boost-bugs] [Boost C++ Libraries] #9006: read_xml segfaults if run from boost::asio::spawn

Subject: [Boost-bugs] [Boost C++ Libraries] #9006: read_xml segfaults if run from boost::asio::spawn
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-08-16 14:11:29


#9006: read_xml segfaults if run from boost::asio::spawn
-----------------------------------------+---------------------------
 Reporter: Mátyás Végh <matyas.vegh@…> | Owner: cornedbee
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: property_tree
  Version: Boost 1.54.0 | Severity: Problem
 Keywords: |
-----------------------------------------+---------------------------
 I've noticed that if read_xml is run through a boost::asio::spawn then
 read_xml encounters a segmentation violation.

 {{{
 #include <boost/property_tree/ptree.hpp>
 #include <iostream>
 #include <boost/property_tree/xml_parser.hpp>
 #include <string>
 #include <sstream>
 #include <boost/asio.hpp>
 #include <boost/asio/spawn.hpp>


 void read() {
         std::cout<<"starting read()"<<std::endl;
         std::string xml = R"phi(<?xml version="1.0"?>
 <start></start>)phi";
         std::stringstream ss(std::move(xml));
         boost::property_tree::ptree pt;
         boost::property_tree::read_xml(ss, pt);
         std::cout<<"ending read()"<<std::endl;
 }

 int main() {
         boost::asio::io_service ios;
         boost::asio::strand mystrand{ios};
         read();
         boost::asio::spawn(mystrand,
 [](boost::asio::yield_context){read();});
         ios.run();
 }

 }}}
 The code above produces
 {{{
 starting read()
 ending read()
 starting read()
 Segmentation fault
 }}}
 Compiled with gcc-4.8.1 and clang-3.3 (release) on Suse Linux 11 x86_64.

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