json: ERROR: ThreadSanitizer: SEGV on unknown address
Description
cd ~/Downloads/json-develop/build/tests/Debug for x in ./test-* ; do ./$x 1> /dev/null || echo $x ; done
./test-cbor_cpp11 ==36891==ERROR: ThreadSanitizer: requested allocation size 0xffffffffffffffff exceeds maximum supported size of 0x10000000000 #0 operator new(unsigned long) <null> (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x7596b) #1 void* std::__1::__libcpp_operator_new<unsigned long>(unsigned long) new:235 (test-cbor_cpp11:x86_64+0x10004abc4)
==36891==HINT: if you don’t care about these errors you may set allocator_may_return_null=1 SUMMARY: ThreadSanitizer: allocation-size-too-big (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x7596b) in operator new(unsigned long) Abort trap: 6 ./test-cbor_cpp11
./test-testsuites_cpp11
ThreadSanitizer:DEADLYSIGNAL ==36941==ERROR: ThreadSanitizer: SEGV on unknown address 0x60000005d000 (pc 0x7ff80f562adb bp 0x7ff7b5762f10 sp 0x7ff7b5762f00 T6880876) ==36941==The signal is caused by a READ memory access. #0 flockfile <null>:197228464 (libsystem_c.dylib:x86_64+0x12ada) #1 fgetc <null>:197228464 (libsystem_c.dylib:x86_64+0x3382e) #2 nlohmann::detail::file_input_adapter::get_character() input_adapters.hpp:56 (test-testsuites_cpp11:x86_64+0x100044ca7) #3 nlohmann::detail::lexer<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >, nlohmann::detail::file_input_adapter>::get() lexer.hpp:1341 (test-testsuites_cpp11:x86_64+0x100044b0b) #4 nlohmann::detail::lexer<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >, nlohmann::detail::file_input_adapter>::skip_bom() lexer.hpp:1480 (test-testsuites_cpp11:x86_64+0x100042db8) #5 nlohmann::detail::lexer<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >, nlohmann::detail::file_input_adapter>::scan() lexer.hpp:1504 (test-testsuites_cpp11:x86_64+0x100042997) #6 nlohmann::detail::parser<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >, nlohmann::detail::file_input_adapter>::get_token() parser.hpp:456 (test-testsuites_cpp11:x86_64+0x1000427cc) #7 nlohmann::detail::parser<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >, nlohmann::detail::file_input_adapter>::parser(nlohmann::detail::file_input_adapter&&, std::__1::function<bool (int, nlohmann::detail::parse_event_t, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >&)>, bool, bool) parser.hpp:73 (test-testsuites_cpp11:x86_64+0x100042738) #8 nlohmann::detail::parser<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >, nlohmann::detail::file_input_adapter>::parser(nlohmann::detail::file_input_adapter&&, std::__1::function<bool (int, nlohmann::detail::parse_event_t, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >&)>, bool, bool) parser.hpp:71 (test-testsuites_cpp11:x86_64+0x1000426ac) #9 nlohmann::detail::parser<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >, nlohmann::detail::file_input_adapter> nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >::parsernlohmann::detail::file_input_adapter(nlohmann::detail::file_input_adapter, std::__1::function<bool (int, nlohmann::detail::parse_event_t, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >&)>, bool, bool) json.hpp:169 (test-testsuites_cpp11:x86_64+0x100041e9d) #10 nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > > nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >::parse<__sFILE*>(__sFILE*&&, std::__1::function<bool (int, nlohmann::detail::parse_event_t, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > >&)>, bool, bool) json.hpp:3992 (test-testsuites_cpp11:x86_64+0x100041b38) #11 _DOCTEST_ANON_FUNC_42() unit-testsuites.cpp:389 (test-testsuites_cpp11:x86_64+0x100006be3) #12 doctest::Context::run() doctest.h:6486 (test-testsuites_cpp11:x86_64+0x100064469) #13 main doctest.h:6571 (test-testsuites_cpp11:x86_64+0x1000663b2) #14 start <null>:197228464 (dyld:x86_64+0x551d)
==36941==Register values:
rax = 0x000000010bd096ac rbx = 0x0000000000000000 rcx = 0x000000010bd096ac rdx = 0x0000000000000103
rdi = 0x0000000000000000 rsi = 0x00007ff80f556154 rbp = 0x00007ff7b5762f10 rsp = 0x00007ff7b5762f00
r8 = 0x0000000000000001 r9 = 0x000000010b925160 r10 = 0x0000000000000000 r11 = 0x0000000000000000
r12 = 0x000000010bd093a0 r13 = 0x00007ff7b5765278 r14 = 0x0000000000000002 r15 = 0x000000010bcf5010
ThreadSanitizer can not provide additional info.
SUMMARY: ThreadSanitizer: SEGV (libsystem_c.dylib:x86_64+0x12ada) in flockfile
==36941==ABORTING
Abort trap: 6
./test-testsuites_cpp11
Reproduction steps
mkdir build cd build cmake -G ‘Xcode’ … xcodebuild -verbose
cd tests/Debug for x in ./test-* ; do ./$x 1> /dev/null || echo $x ; done
Expected vs. actual results
SUCCESS! for all tests
Minimal code example
No response
Error messages
No response
Compiler and operating system
Xcode 13.4.1 Build version 13F100, Clang 13.1.6 (clang-1316.0.21.2.5), macOS-12.4-x86_64-i386-64bit
Library version
json-develop-master
Validation
- The bug also occurs if the latest version from the
develop
branch is used. - I can successfully compile and run the unit tests.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 23 (18 by maintainers)
Commits related to this issue
- :children_crossing: add error message if test suite cannot be found Fixes #3584 — committed to nlohmann/json by nlohmann 2 years ago
- :children_crossing: add error message if test suite cannot be found Fixes #3584 — committed to nlohmann/json by nlohmann 2 years ago
- :children_crossing: add error message if test suite cannot be found Fixes #3584 — committed to nlohmann/json by nlohmann 2 years ago
- Add error message if test suite cannot be found (#3585) * :children_crossing: add error message if test suite cannot be found Fixes #3584 — committed to nlohmann/json by nlohmann 2 years ago
- :boom: throw exception if nullptr is passed to parse function Addresses #3584 — committed to nlohmann/json by nlohmann 2 years ago
- Add assertion if nullptr is passed to parse function (#3593) Addresses #3584 — committed to nlohmann/json by nlohmann 2 years ago
Please have a look at https://github.com/nlohmann/json/pull/3593 where an exception is thrown if a passed file pointer is null.
double check, both your Json library and the client side; we can achieve the famous “out of the box” experience of Apple, for your Json library clients.
Why you nlohmann innovated this Json library besides bson, cjson, fastjson, simplejson, ujson, cppjson, and other famous existing Json libraries? Clients and contributors believe we can. make it better.