Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

corruption when parse from string #2603

Closed
yqynju opened this issue Jan 22, 2021 · 5 comments
Closed

corruption when parse from string #2603

yqynju opened this issue Jan 22, 2021 · 5 comments
Labels
kind: bug state: needs more info the author of the issue needs to provide more details

Comments

@yqynju
Copy link

yqynju commented Jan 22, 2021

hello,
parse from raw sting

nlohmann::json::parse(R"({ "exception" : "",
                    "retr_cost" : "",
                    "li": "",
                    "q" : {"text" : "", "l" : "", "t" : [], "limit" : 15, "th" : 0,"w" : [] },
                    "tc" : {"hwseg":""},
                    "tb" : {"time_cost": "", "result" : []},
                    "tg" : {"time_cost": "", "result" : [] },
                    "tt" : { "time_cost": "", "pw" : "", "pd" : [], "result" : [] },
                    "sn" : { "time_cost": "", "result" : [] },
                    "sv" : { "time_cost": "", "result" : [] },
                    "vb" : { "time_cost": "", "result" : [] },
                    "bd" : { "time_cost":"", "result" : [] },
                    "ee" : { "time_cost" : "", "result" : [] },
                    "bd" : { "time_cost" : "", "result" : [] },
                    "hh" : { "time_cost" : "", "result" : [] }})"

with 64 thread, it come the corrupetion with flowwing:

/usr/include/c++/4.8.2/ext/new_allocator.h:120
/usr/include/c++/4.8.2/bits/stl_map.h:465
json-for-modern-cpp/include/nlohmann/detail/input/json_sax.hpp:221
json-for-modern-cpp/include/nlohmann/detail/input/parser.hpp:120
/usr/include/c++/4.8.2/bits/basic_string.h:539
src/server/server_core.cpp:133

version:
json-for-modern-cpp-3.6.1

@yqynju
Copy link
Author

yqynju commented Jan 22, 2021

#0 0x00002afebb2d4417 in raise () from /lib64/libc.so.6
#1 0x00002afebb2d5c48 in abort () from /lib64/libc.so.6
#2 0x00002afebb314647 in __libc_message () from /lib64/libc.so.6
#3 0x00002afebb31a1d4 in malloc_printerr () from /lib64/libc.so.6
#4 0x00002afebb31e037 in _int_malloc () from /lib64/libc.so.6
#5 0x00002afebb31f8bc in malloc () from /lib64/libc.so.6
#6 0x00002afebaade1bd in operator new(unsigned long) () from /lib64/libstdc++.so.6
#7 0x0000556f70198d59 in allocate (__n=1, this=)
at /usr/include/c++/4.8.2/ext/new_allocator.h:104
#8 _M_get_node (this=) at /usr/include/c++/4.8.2/bits/stl_tree.h:370
#9 _M_create_node<const std::piecewise_construct_t&, std::tuple<const std::basic_string<char, std::char_traits, std::allocator >&>, std::tuple<> > (this=0x2b012c0245b0)
at /usr/include/c++/4.8.2/bits/stl_tree.h:403
#10 std::_Rb_tree<std::string, std::pair<std::string const, nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >, std::_Select1st<std::pair<std::string const, nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > >, std::lessstd::string, std::allocator<std::pair<std::string const, nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > > >::_M_emplace_hint_unique<std::piecewise_construct_t const&, std::tuple<std::string const&>, std::tuple<> >(std::_Rb_tree_const_iterator<std::pair<std::string const, nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > >, std::piecewise_construct_t const&, std::tuple<std::string const&>&&, std::tuple<>&&) (
this=this@entry=0x2b012c0245b0, __pos=..., __pos@entry=...) at /usr/include/c++/4.8.2/bits/stl_tree.h:1669
#11 0x0000556f701a96bc in std::map<std::string, nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer>, std::lessstd::string, std::allocator<std::pair<std::string const, nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > > >::operator[] (this=0x2b012c0245b0, __k="result")
at /usr/include/c++/4.8.2/bits/stl_map.h:465
#12 0x0000556f701a9fe2 in key (val="result", this=0x2b01be622f80)
at /home/yqy/com/thirdparty/json-for-modern-cpp/include/nlohmann/detail/input/json_sax.hpp:221
#13 nlohmann::detail::parser<nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >::sax_parse_internal<nlohmann::detail::json_sax_dom_parser<nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > > (this=0x2b01be623160, sax=sax@entry=0x2b01be622f80)
at com/thirdparty/json-for-modern-cpp/include/nlohmann/detail/input/parser.hpp:405
#14 0x0000556f701af8f7 in nlohmann::detail::parser<nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >::parse (
this=this@entry=0x2b01be623160, strict=strict@entry=true, result=...)
at com/thirdparty/json-for-modern-cpp/include/nlohmann/detail/input/parser.hpp:116

@nlohmann
Copy link
Owner

What do you mean with "with 64 thread"?

@nlohmann nlohmann added the state: needs more info the author of the issue needs to provide more details label Jan 23, 2021
@yqynju
Copy link
Author

yqynju commented Jan 23, 2021

app runs parallel, which contains 64 threads.

it come with the above corruption. or below corruption:

#0 nlohmann::detail::serializer<nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >::dump_escaped (this=0x7fdc106f6f90, s=..., ensure_ascii=false)
at json-for-modern-cpp/include/nlohmann/detail/output/serializer.hpp:312
#1 0x000055dd147dc413 in nlohmann::detail::serializer<nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >::dump (this=0x7fdc106f6f90, val=...,
pretty_print=, ensure_ascii=, indent_step=0, current_indent=0) at json-for-modern-cpp/include/nlohmann/detail/output/serializer.hpp:162
#2 0x000055dd147d7702 in dump (error_handler=nlohmann::detail::strict, ensure_ascii=false, indent_char=32 ' ', indent=-1, this=0x7fdc106f7358)

@nlohmann
Copy link
Owner

The above code only contains a call to parse, but your stack trace calls dump. Can you please share a minimal working example?

@nlohmann
Copy link
Owner

@yqynju Can you provide more information on this issue? If it only occurs in multi-threaded environments, can you maybe run it with TSAN?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug state: needs more info the author of the issue needs to provide more details
Projects
None yet
Development

No branches or pull requests

2 participants