-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
issue in free() #1886
Comments
This is odd as the library does not leak any memory or has any known memory issues. If I had to guess, it is unrelated to the library and it is more likely that some thread is messing with the memory. Can you reproduce the issue? If so, could you try to run it with Valgrind or ASAN? |
Thanks for the reply. It might not be the issue with the library. I will observe a few more days and update the status. I will close this issue if it is not relevant. |
Unfortunately I do re-create the error, after running like 30 mins. It is not exactly the same but very similar, and if I don't create a json object, the program doesn't create similar memory error. I am using single include json.hpp in master branch. Which branch is more stable, master or dev ? The error: Thread 1 "TWS_Client" received signal SIGABRT, Aborted. |
Quite strange, the problem appears to happen in dump(). I print out the values in the json object "jud", and there is no problem: I use jud.dump(-1, ' ', false, json::error_handler_t::ignore), and the error becomes: Thread 1 "TWS_Client" received signal SIGABRT, Aborted. |
The second crash is happening in Nevertheless, your best best as @nlohmann stated, is to use a tool like ASAN Note that ASAN inevitably slows down the program execution during debug, so it would be handy if you could run some simulations which feed the program data at much higher rate. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi nlohmann,
Don't know if anyone has encountered this issue before, and I am not sure if it is and issue with the library.
I just create a json object, and dump it, publish the result to redis, whenever I receive a message from a TCP socket. However, after running for 15-30 mins, I have a memory error.
The code is very simple:
json jud=json::object();
string timenow = currentTimeStr();
jud["Msg_seq"]=epochTimeStr();
jud["Time"]=timenow;
jud["TimeArrive"]=timenow;
jud["Exchange"]="IB";
jud["Symbol"]="USD_JPY";
string judstr = jud.dump();
redis_cli_.publish("UPDATEx|USD_JPY.IB", judstr, [](cpp_redis::reply &reply) {
//std::cout << "publish UPDATE: " << reply << std::endl;
});
The error:
free(): invalid next size (fast)
Thread 1 "TWS_Client" received signal SIGABRT, Aborted.
0x00007ffff72abae0 in raise () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install libgcc-7.3.1-6.amzn2.0.4.x86_64 libstdc++-7.3.1-6.amzn2.0.4.x86_64
(gdb)
(gdb) bt
#0 0x00007ffff72abae0 in raise () from /lib64/libc.so.6
#1 0x00007ffff72acf88 in abort () from /lib64/libc.so.6
#2 0x00007ffff72ebb94 in __libc_message () from /lib64/libc.so.6
#3 0x00007ffff72f180a in malloc_printerr () from /lib64/libc.so.6
#4 0x00007ffff72f330b in _int_free () from /lib64/libc.so.6
#5 0x0000555555587e60 in void __gnu_cxx::new_allocator<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >::destroy<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >(std::__cxx11::basic_string<char, std::char_traits, std::allocator >) ()
#6 0x00005555555847ea in void std::allocator_traits<std::allocator<std::__cxx11::basic_string<char, std::char_traits, std::allocator > > >::destroy<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >(std::allocator<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >&, std::__cxx11::basic_string<char, std::char_traits, std::allocator >) ()
#7 0x000055555558032a in nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer>::json_value::destroy(nlohmann::detail::value_t) ()
#8 0x000055555557c96b in nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer>::~basic_json() ()
#9 0x000055555558024f in nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer>::json_value::destroy(nlohmann::detail::value_t) ()
#10 0x000055555557c96b in nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer>::~basic_json() ()
#11 0x0000555555572d3c in TestCppClient::updateMktDepth(long, int, int, int, double, int) ()
#12 0x00005555555c3bb1 in EDecoder::processMarketDepthMsg(char const*, char const*) ()
#13 0x00005555555cb881 in EDecoder::parseAndProcessMsg(char const*&, char const*) ()
#14 0x00005555555e213c in EReader::processMsgs() ()
#15 0x00005555555657b7 in TestCppClient::processMessages() ()
#16 0x000055555559fb1e in main ()
The text was updated successfully, but these errors were encountered: