My program to load json file gives SEGV intermittently with following signature.
034613:/../lib/libtcmalloc.so.4(operator new(unsigned long) 0xc9)[0x7f493d215f99]
/lib/libjsoncpp.so(Json::Value::Value(Json::Value const&) 0xcc)[0x7f493ffa7f3a]
lib/libjsoncpp.so(Json::Value::operator=(Json::Value const&) 0x23)[0x7f493ffa81fd]lib/libjsoncpp.so
(Json::Reader::readObject(Json::Reader::Token&) 0x60)
[0x7f493ffa1cae]lib/libjsoncpp.so(Json::Reader::readValue() 0x103)[0x7f493ffa10f7]\n",
and the code which results in this error is
ifstream config_stream(config_file);
string config_data((std::istreambuf_iterator<char>(config_stream)),
std::istreambuf_iterator<char>());
Json::Reader reader(Json::Features::all());
Json::Value json_parsed_data;
CHECK(reader.parse(config_data, json_parsed_data))
Potential reason from related artickles i checked was this could happen if the json file is too large and has a lot of nesting, but that's not my case.
My json file has 1 level of nesting and about 100 entries, overall file is not more than 400 lines, Anyone faced similar issue while reading from json files in c++ ?