Skip to content

json::parse is not thread safe? #1712

Description

@Shawn1993

This is the backtrace from gdb:

#0  0x00007ffff22b13f7 in raise () from /opt/compiler/gcc-4.8.2/lib/libc.so.6
#1  0x00007ffff22b27d8 in abort () from /opt/compiler/gcc-4.8.2/lib/libc.so.6
#2  0x000000000082674e in TCMalloc_CRASH_internal (dump_stats=false, filename=<value optimized out>, line_number=<value optimized out>, format=0xaee090 "Attempt to free invalid pointer: %p\n", ap=0x7fffd95edc40) at src/internal_logging.cc:77
#3  0x000000000082693b in TCMalloc_CrashReporter::PrintfAndDie (this=<value optimized out>, format=0x0) at src/internal_logging.cc:94
#4  0x000000000081f6e6 in (anonymous namespace)::InvalidFree (ptr=0x6) at src/internal_logging.h:88
#5  0x00000000008ce886 in do_free_with_callback (p=0x26f6422) at src/tcmalloc.cc:1129
#6  0x00000000008ce886 in do_free (p=0x26f6422)
#7  0x00000000008ce886 in tc_delete (p=0x26f6422)
#8  0x000000000046fec9 in deallocate (this=0x7fffd95ee498) at /home/opt/gcc-4.8.2.bpkg-r2/gcc-4.8.2.bpkg-r2/include/c++/4.8.2/ext/new_allocator.h:110
#9  _M_deallocate (this=0x7fffd95ee498) at /home/opt/gcc-4.8.2.bpkg-r2/gcc-4.8.2.bpkg-r2/include/c++/4.8.2/bits/stl_vector.h:174
#10 _M_emplace_back_aux<char> (this=0x7fffd95ee498) at /home/opt/gcc-4.8.2.bpkg-r2/gcc-4.8.2.bpkg-r2/include/c++/4.8.2/bits/vector.tcc:430
#11 emplace_back<char> (this=0x7fffd95ee498) at /home/opt/gcc-4.8.2.bpkg-r2/gcc-4.8.2.bpkg-r2/include/c++/4.8.2/bits/vector.tcc:101
#12 push_back (this=0x7fffd95ee498) at /home/opt/gcc-4.8.2.bpkg-r2/gcc-4.8.2.bpkg-r2/include/c++/4.8.2/bits/stl_vector.h:920
#13 nlohmann::detail::lexer<nlohmann::basic_json<std::map, std::vector, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >::get (this=0x7fffd95ee498)
    at bc_out/baidu/kg/json/output/include/nlohmann/json.hpp:6758
#14 0x00000000004709fb in nlohmann::detail::lexer<nlohmann::basic_json<std::map, std::vector, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >::scan_string (
    this=0x7fffd95ee498) at bc_out/baidu/kg/json/output/include/nlohmann/json.hpp:5744
#15 0x0000000000473e24 in get_token (this=0x7fffd95ee470, sax=0x7fffd95ee340) at bc_out/baidu/kg/json/output/include/nlohmann/json.hpp:7467
#16 nlohmann::detail::parser<nlohmann::basic_json<std::map, std::vector, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >::sax_parse_internal<nlohmann::detail::json_sax_dom_parser<nlohmann::basic_json<> > >(nlohmann::detail::json_sax_dom_parser<nlohmann::basic_json<std::map, std::vector, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > *) (this=0x7fffd95ee470, sax=0x7fffd95ee340) at bc_out/baidu/kg/json/output/include/nlohmann/json.hpp:7206
#17 0x0000000000479c5e in nlohmann::detail::parser<nlohmann::basic_json<std::map, std::vector, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >::parse (
    this=0x7fffd95ee470, strict=Unhandled dwarf expression opcode 0xf3
) at bc_out/baidu/kg/json/output/include/nlohmann/json.hpp:7130
#18 0x0000000000482894 in nlohmann::basic_json<std::map, std::vector, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer>::parse (i=Unhandled dwarf expression opcode 0xf3
)
    at bc_out/baidu/kg/json/output/include/nlohmann/json.hpp:18870
#19 0x00000000004822b6 in textract::HttpServiceTask::entity (this=Unhandled dwarf expression opcode 0xf3
) at baidu/intelligent-search/text-extractor/src/server/http_service_task.cpp:118
#20 0x00000000004832fe in textract::HttpService::CallMethod (this=0x7fffffffd2e0, method=Unhandled dwarf expression opcode 0xf3
) at bc_out/baidu/intelligent-search/text-extractor/proto/server.pb.cc:534
#21 0x0000000000524077 in baidu::rpc::policy::ProcessHttpRequest(baidu::rpc::InputMessageBase*) () at baidu/base/baidu-rpc/src/baidu/rpc/policy/http_rpc_protocol.cpp:1336
#22 0x000000000059505a in baidu::rpc::ProcessInputMessage(void*) () at baidu/base/baidu-rpc/src/baidu/rpc/input_messenger.cpp:134
#23 0x000000000059632f in baidu::rpc::InputMessenger::OnNewMessages(baidu::rpc::Socket*) () at baidu/base/baidu-rpc/src/baidu/rpc/input_messenger.cpp:344
#24 0x00000000004bfc9d in baidu::rpc::Socket::ProcessEvent(void*) () at baidu/base/baidu-rpc/src/baidu/rpc/socket.cpp:1110
#25 0x000000000063c8da in bthread::TaskGroup::task_runner(long) () at baidu/base/bthread/bthread/task_group.cpp:293
#26 0x000000000063ceeb in bthread::TaskGroup::run_main_task() () at baidu/base/bthread/bthread/task_group.cpp:152
#27 0x0000000000639a4d in bthread::TaskControl::worker_thread(void*) () at baidu/base/bthread/bthread/task_control.cpp:73
#28 0x00007ffff7bc61c3 in start_thread () from /opt/compiler/gcc-4.8.2/lib/libpthread.so.0
#29 0x00007ffff236312d in clone () from /opt/compiler/gcc-4.8.2/lib/libc.so.6

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions