I developed a simple wrapper that encapsulates a JSONObject with Boost Property trees. The problem is a segmentation fault in this code:
void JSONObject::parse(const std::string &text)
{
std::istringstream ss(text);
boost::property_tree::read_json(ss, *pt);
}
A bit of context, I am using JSON for message serialization. If the program uses only one thread it works without problems. But if the program uses two threads in gives a segmentation fault in the last line of the above code.
Each thread has its own JSONObject object and none of the variables are shared between the threads. My idea is that maybe the stream is not thread safe internally.
Can anyone help me?
I found the problem. For boost property tree to be thread safe it is necessary to add this flag:
#define BOOST_SPIRIT_THREADSAFE
After adding this flag the code run without any problems.
Thanks for the help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With