-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Dumping core when reading invalid file #1975
Comments
The following example https://godbolt.org/z/zpxg_c does not dump core. Any idea what I'm doing wrong? |
Hi @ilya1725 , this |
@dota17 , sorry, what? The JSON source file is attached fine. This isn't the problem. @t-b: I've tried the code in the example and it dumps core just fine. The Compiler Explorer just doesn't show it. One way to avoid the direct core dump is to set the |
@ilya1725 Hmmm, you're right, I got a hasty conclusion, my last point is really wrong, even though they are the same types of errors. |
Hello:
I have your module in my application. Compiled with exceptions disabled and -O2 optimization.
I was trying to read an invalid JSON file:
{ "sn": 1, "name": "First bird" "type": 1, "flags": { "tied_down": true } }
const std::ifstream config_file(argv[1]); nlohmann::json j; config_file >> j;
The application dumps core in the last line instead of returning an error:
Program received signal SIGABRT, Aborted. __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory. (gdb) bt #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 #1 0x00007f0de58f8899 in __GI_abort () at abort.c:79 #2 0x000055d061bb677d in nlohmann::detail::json_sax_dom_callback_parser<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >::parse_error (this=<optimized out>, this=<optimized out>, ex=...) at /usr/include/c++/9/bits/basic_string.h:1936 #3 nlohmann::detail::json_sax_dom_parser<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >::parse_error (this=<optimized out>, this=<optimized out>, ex=...) at /develop/build/_deps/nlohmann_json-src/single_include/nlohmann/json.hpp:4806 #4 nlohmann::detail::parser<nlohmann::basic_json<std::map, std::vector, std::__cxx11::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<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > > (this=<optimized out>, sax=<optimized out>) at /develop/build/_deps/nlohmann_json-src/single_include/nlohmann/json.hpp:8987 #5 0x000055d061bb6dbc in nlohmann::detail::parser<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >::parse ( this=0x7fff73960a80, strict=<optimized out>, result=...) at /usr/include/c++/9/bits/stl_vector.h:94 #6 0x000055d061bb76c3 in nlohmann::operator>> (i=..., j=...) at /develop/build/_deps/nlohmann_json-src/single_include/nlohmann/json.hpp:9104 #7 0x000055d061ba888a in main (argc=2, argv=0x7fff73960ee8) at /develop/apps/apps/test_application/src/test_application.cpp:33
Thank you.
The text was updated successfully, but these errors were encountered: