2

We are using boost in our project. We are not linking any boost libraries but we are including boost header files like boost/property_tree/ptree.hpp.

We are calling read_json from multiple threads (not boost threads but posix threads) and we are getting crashes at read_json() function. Now we included BOOST_SPIRIT_THREADSAFE before including header files as boost json parser is not thread safe and every thing is working fine. But our reviewer is not accepting this change and he is pointing to the below link

http://www.boost.org/doc/libs/1_60_0/libs/spirit/classic/doc/grammar.html

As this page mentioned "On the other hand, if a grammar is intended to be used in multithreaded code, we should then define BOOST_SPIRIT_THREADSAFE before including any spirit header files. In this case it will also be required to link against Boost.Threads"

But do we really need to link with the Boost.Threads library as we are not using boost threads and my understanding is boost threads internally will use posix threads on Linux platform. Can any one please let me know if I am wrong.

sehe
  • 374,641
  • 47
  • 450
  • 633
kadina
  • 5,042
  • 4
  • 42
  • 83

1 Answers1

3

The reviewer is linking to "1.60.0" documentation... of Classic Spirit.

Spirit classic has been obsolete for a decade or more.

What's more, Boost Property Tree has rewritten it's parsers: it doesn't use Spirit at all in 1.60.0. This has been the case for some versions.

Note there can be issues when using Property Tree outside the main entry-point, see e.g.:

Community
  • 1
  • 1
sehe
  • 374,641
  • 47
  • 450
  • 633
  • This means If we are using old boost code, we still need to use that flag. One thing I can't understand is if we are using read_json in different processes, why do we need this flag, as the process addresses are completely different. – kadina Mar 17 '16 at 20:55