Opened 9 years ago

#9006 new Bugs

read_xml segfaults if run from boost::asio::spawn

Reported by: Mátyás Végh <matyas.vegh@…> Owned by: Sebastian Redl
Milestone: To Be Determined Component: property_tree
Version: Boost 1.54.0 Severity: Problem
Keywords: Cc:

Description

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.

Change History (0)

Note: See TracTickets for help on using tickets.