open-source-parsers / open-source-parsers/jsoncpp
Segfault on construction of class using json in a multi threaded application
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 8.9k
- Forks
- 2.7k
- Avg merge
- 31m
- Merged PRs (30d)
- 1
Description
Describe the bug
Segfault on construction of class using json in a multi threaded application.
gdb output:
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
0x00007fffe99a535f in ?? () from /usr/lib/x86_64-linux-gnu/libjsoncpp.so.1
(gdb) bt
#0 0x00007fffe99a535f in ?? () from /usr/lib/x86_64-linux-gnu/libjsoncpp.so.1
#1 0x00007ffff7de5733 in call_init (env=0x7fffffffd3e8, argv=0x7fffffffd3d8, argc=1, l=<optimized out>) at dl-init.c:72
#2 _dl_init (main_map=0x7ffff7ffe170, argc=1, argv=0x7fffffffd3d8, env=0x7fffffffd3e8) at dl-init.c:119
#3 0x00007ffff7dd60ca in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#4 0x0000000000000001 in ?? ()
#5 0x00007fffffffd7eb in ?? ()
#6 0x0000000000000000 in ?? ()
If I remove the following lines of code the issue goes away.
#if JSON_USE_NULLREF
// for backwards compatibility, we'll leave these global references around, but
// DO NOT use them in JSONCPP library code any more!
// static
Value const& Value::null = Value::nullSingleton();
// static
Value const& Value::nullRef = Value::nullSingleton();
#endif
To Reproduce
Steps to reproduce the behavior:
- I will work on a test case but I have been able to reproduce on multiple machines.
Desktop (please complete the following information):
- Ubuntu 18.04.3 LTS
- Intel® Core™ i7-4700MQ CPU @ 2.40GHz × 8
- Quadro K1100M/PCIe/SSE2
- GNOME 3.28.2
- 64-bit
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the JSON_USE_NULLREF block defining Value::null and Value::nullRef, and inspect the gdb backtrace during library initialization. Build a minimal multithreaded reproducer, comparing behavior with those references present and removed. Done when the segfault is reproducible and a regression test or documented fix verifies construction no longer crashes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100