Skip to content

0.10.5 test segfault on FreeBSD when compiled with gcc #338

Closed
@AMDmi3

Description

@AMDmi3

I've tried to update FreeBSD port of jsoncpp to 0.10.5 and run tests, and it turned out that test crash on FreeBSD 9.x which uses gcc. Gcc there is old, so I've tried newer (4.8, 4.9) gcc on FreeBSD 10.2, and it still crashes.

The crash is most mysterious and I couldn't figure it out. It crashes in copy ctor of Value in root["array"] = Json::Value::nullRef; because other is a null reference, while it should be constructed from Json::Value::nullRef which is pretty valid reference.

(gdb) run
Starting program: /ssd/portstrees/batchports-mem/devel/jsoncpp/work/jsoncpp-0.10.5/bin/linux-gcc-FreeBSD/test_lib_json 
Testing ValueTest/checkNormalizeFloatingPointStr: OK
Testing ValueTest/memberCount: OK
Testing ValueTest/objects: OK
Testing ValueTest/arrays: OK
Testing ValueTest/arrayIssue252: [New Thread 801c06400 (LWP 101731)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 801c06400 (LWP 101731)]
0x0000000800abb6a1 in Json::Value::Value (this=0x7fffffffdfc0, other=...) at src/lib_json/json_value.cpp:388
388           comments_(0)
(gdb) bt full
#0  0x0000000800abb6a1 in Json::Value::Value (this=0x7fffffffdfc0, other=...) at src/lib_json/json_value.cpp:388
No locals.
#1  0x0000000800abba3e in Json::Value::operator= (this=0x801c17310, other=...) at src/lib_json/json_value.cpp:454
        temp = {static nullRef = @0x800acdd30, static null = {static nullRef = @0x800acdd30, static null = <same as static member of an already seen type>, static minLargestInt = -9223372036854775808, static maxLargestInt = 9223372036854775807, 
            static maxLargestUInt = 18446744073709551615, static minInt = -2147483648, static maxInt = 2147483647, static maxUInt = 4294967295, static minInt64 = -9223372036854775808, static maxInt64 = 9223372036854775807, 
            static maxUInt64 = 18446744073709551615, value_ = {int_ = 0, uint_ = 0, real_ = 0, bool_ = false, string_ = 0x0, map_ = 0x0}, type_ = Json::nullValue, allocated_ = 0, comments_ = 0x0}, static minLargestInt = -9223372036854775808, 
          static maxLargestInt = 9223372036854775807, static maxLargestUInt = 18446744073709551615, static minInt = -2147483648, static maxInt = 2147483647, static maxUInt = 4294967295, static minInt64 = -9223372036854775808, 
          static maxInt64 = 9223372036854775807, static maxUInt64 = 18446744073709551615, value_ = {int_ = 140737488347120, uint_ = 140737488347120, real_ = 6.9533558074294752e-310, bool_ = 240, string_ = 0x7fffffffdff0 "\260\340\377\377\377\177", 
            map_ = 0x7fffffffdff0}, type_ = Json::nullValue, allocated_ = 0, comments_ = 0x7fffffffdff0}
#2  0x00000000004098d4 in TestValueTestarrayIssue252::runTestCase (this=0x801c21180) at src/test_lib_json/main.cpp:265
        count = 5
        root = {static nullRef = @0x800acdd30, static null = {static nullRef = @0x800acdd30, static null = <same as static member of an already seen type>, static minLargestInt = -9223372036854775808, static maxLargestInt = 9223372036854775807, 
            static maxLargestUInt = 18446744073709551615, static minInt = -2147483648, static maxInt = 2147483647, static maxUInt = 4294967295, static minInt64 = -9223372036854775808, static maxInt64 = 9223372036854775807, 
            static maxUInt64 = 18446744073709551615, value_ = {int_ = 0, uint_ = 0, real_ = 0, bool_ = false, string_ = 0x0, map_ = 0x0}, type_ = Json::nullValue, allocated_ = 0, comments_ = 0x0}, static minLargestInt = -9223372036854775808, 
          static maxLargestInt = 9223372036854775807, static maxLargestUInt = 18446744073709551615, static minInt = -2147483648, static maxInt = 2147483647, static maxUInt = 4294967295, static minInt64 = -9223372036854775808, 
          static maxInt64 = 9223372036854775807, static maxUInt64 = 18446744073709551615, value_ = {int_ = 34389258592, uint_ = 34389258592, real_ = 1.6990551256258117e-313, bool_ = 96, string_ = 0x801c27160 "\245\245\245\245\245\245\245\245", 
            map_ = 0x801c27160}, type_ = Json::objectValue, allocated_ = 0, comments_ = 0x0}
        item = {static nullRef = @0x800acdd30, static null = {static nullRef = @0x800acdd30, static null = <same as static member of an already seen type>, static minLargestInt = -9223372036854775808, static maxLargestInt = 9223372036854775807, 
            static maxLargestUInt = 18446744073709551615, static minInt = -2147483648, static maxInt = 2147483647, static maxUInt = 4294967295, static minInt64 = -9223372036854775808, static maxInt64 = 9223372036854775807, 
            static maxUInt64 = 18446744073709551615, value_ = {int_ = 0, uint_ = 0, real_ = 0, bool_ = false, string_ = 0x0, map_ = 0x0}, type_ = Json::nullValue, allocated_ = 0, comments_ = 0x0}, static minLargestInt = -9223372036854775808, 
          static maxLargestInt = 9223372036854775807, static maxLargestUInt = 18446744073709551615, static minInt = -2147483648, static maxInt = 2147483647, static maxUInt = 4294967295, static minInt64 = -9223372036854775808, 
          static maxInt64 = 9223372036854775807, static maxUInt64 = 18446744073709551615, value_ = {int_ = 140737488347248, uint_ = 140737488347248, real_ = 6.9533558074357993e-310, bool_ = 112, string_ = 0x7fffffffe070 "\240\340\377\377\377\177", 
            map_ = 0x7fffffffe070}, type_ = Json::nullValue, allocated_ = 0, comments_ = 0x0}
#3  0x000000000042b2a5 in JsonTest::TestCase::run (this=0x801c21180, result=...) at src/test_lib_json/jsontest.cpp:226
No locals.
#4  0x000000000042b4b8 in JsonTest::Runner::runTestAt (this=0x7fffffffe370, index=4, result=...) at src/test_lib_json/jsontest.cpp:258
        test = 0x801c21180
        status = 0x7fffffffe1d0 "\001"
#5  0x000000000042b63c in JsonTest::Runner::runAllTest (this=0x7fffffffe370, printSummary=true) at src/test_lib_json/jsontest.cpp:277
        result = {predicateId_ = 1, predicateStackTail_ = 0x7fffffffe238, failures_ = {<std::_Deque_base<JsonTest::Failure, std::allocator<JsonTest::Failure> >> = {
              _M_impl = {<std::allocator<JsonTest::Failure>> = {<__gnu_cxx::new_allocator<JsonTest::Failure>> = {<No data fields>}, <No data fields>}, _M_map = 0x801c16140, _M_map_size = 8, _M_start = {_M_cur = 0x801c19800, _M_first = 0x801c19800, 
                  _M_last = 0x801c199e0, _M_node = 0x801c16158}, _M_finish = {_M_cur = 0x801c19800, _M_first = 0x801c19800, _M_last = 0x801c199e0, _M_node = 0x801c16158}}}, <No data fields>}, name_ = {static npos = <optimized out>, 
            _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x801c270b8 "ValueTest/arrayIssue252"}}, rootPredicateNode_ = {id_ = 0, file_ = 0x7fffffffe300 "", line_ = 4294959904, 
            expr_ = 0x7fffffffe270 "", next_ = 0x0, failure_ = 0x801c16098}, lastUsedPredicateId_ = 0, messageTarget_ = 0x0}
        index = 4
        count = 50
        failures = {<std::_Deque_base<JsonTest::TestResult, std::allocator<JsonTest::TestResult> >> = {_M_impl = {<std::allocator<JsonTest::TestResult>> = {<__gnu_cxx::new_allocator<JsonTest::TestResult>> = {<No data fields>}, <No data fields>}, 
              _M_map = 0x801c16100, _M_map_size = 8, _M_start = {_M_cur = 0x801c19600, _M_first = 0x801c19600, _M_last = 0x801c197f8, _M_node = 0x801c16118}, _M_finish = {_M_cur = 0x801c19600, _M_first = 0x801c19600, _M_last = 0x801c197f8, 
                _M_node = 0x801c16118}}}, <No data fields>}
#6  0x000000000042bbdf in JsonTest::Runner::runCommandLine (this=0x7fffffffe370, argc=1, argv=0x7fffffffe438) at src/test_lib_json/jsontest.cpp:358
        subrunner = {tests_ = {<std::_Deque_base<JsonTest::TestCase* (*)(), std::allocator<JsonTest::TestCase* (*)()> >> = {
              _M_impl = {<std::allocator<JsonTest::TestCase* (*)()>> = {<__gnu_cxx::new_allocator<JsonTest::TestCase* (*)()>> = {<No data fields>}, <No data fields>}, _M_map = 0x801c160c0, _M_map_size = 8, _M_start = {_M_cur = 0x801c19400, 
                  _M_first = 0x801c19400, _M_last = 0x801c19600, _M_node = 0x801c160d8}, _M_finish = {_M_cur = 0x801c19400, _M_first = 0x801c19400, _M_last = 0x801c19600, _M_node = 0x801c160d8}}}, <No data fields>}}
        succeeded = false
#7  0x0000000000423a99 in main (argc=1, argv=0x7fffffffe438) at src/test_lib_json/main.cpp:2336
        runner = {tests_ = {<std::_Deque_base<JsonTest::TestCase* (*)(), std::allocator<JsonTest::TestCase* (*)()> >> = {
              _M_impl = {<std::allocator<JsonTest::TestCase* (*)()>> = {<__gnu_cxx::new_allocator<JsonTest::TestCase* (*)()>> = {<No data fields>}, <No data fields>}, _M_map = 0x801c16080, _M_map_size = 8, _M_start = {_M_cur = 0x801c19200, 
                  _M_first = 0x801c19200, _M_last = 0x801c19400, _M_node = 0x801c16098}, _M_finish = {_M_cur = 0x801c19390, _M_first = 0x801c19200, _M_last = 0x801c19400, _M_node = 0x801c16098}}}, <No data fields>}}
(gdb) frame 1
#1  0x0000000800abba3e in Json::Value::operator= (this=0x801c17310, other=...) at src/lib_json/json_value.cpp:454
454       Value temp(other);
(gdb) print other
$1 = (const Json::Value &) @0x0: <error reading variable>
(gdb) frame 2
#2  0x00000000004098d4 in TestValueTestarrayIssue252::runTestCase (this=0x801c21180) at src/test_lib_json/main.cpp:265
265       root["array"] = Json::Value::nullRef;
(gdb) print Json::Value::nullRef
$2 = (const Json::Value &) @0x800acdd30: {static nullRef = @0x800acdd30, static null = {static nullRef = @0x800acdd30, static null = <same as static member of an already seen type>, static minLargestInt = -9223372036854775808, 
    static maxLargestInt = 9223372036854775807, static maxLargestUInt = 18446744073709551615, static minInt = -2147483648, static maxInt = 2147483647, static maxUInt = 4294967295, static minInt64 = -9223372036854775808, static maxInt64 = 9223372036854775807, 
    static maxUInt64 = 18446744073709551615, value_ = {int_ = 0, uint_ = 0, real_ = 0, bool_ = false, string_ = 0x0, map_ = 0x0}, type_ = Json::nullValue, allocated_ = 0, comments_ = 0x0}, static minLargestInt = -9223372036854775808, 
  static maxLargestInt = 9223372036854775807, static maxLargestUInt = 18446744073709551615, static minInt = -2147483648, static maxInt = 2147483647, static maxUInt = 4294967295, static minInt64 = -9223372036854775808, static maxInt64 = 9223372036854775807, 
  static maxUInt64 = 18446744073709551615, value_ = {int_ = 0, uint_ = 0, real_ = 0, bool_ = false, string_ = 0x0, map_ = 0x0}, type_ = Json::nullValue, allocated_ = 0, comments_ = 0x0}
(gdb) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions