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

Parse causing crash on android. Cannot catch. #2021

Closed
Burnrate opened this issue Apr 1, 2020 · 6 comments
Closed

Parse causing crash on android. Cannot catch. #2021

Burnrate opened this issue Apr 1, 2020 · 6 comments
Labels
kind: bug solution: invalid the issue is not related to the library

Comments

@Burnrate
Copy link

Burnrate commented Apr 1, 2020

  • What is the issue you have?

Running and android app on android 10. Sometimes, when using nlohmann::json::parse my application will crash. I am parsing simple strings like {"stringy":{"value":"a string"}}. Sometimes it works and I can use the resulting object. Mostly it crashes with the error:
0xebadde09 skipped times: 0
A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x227245ef88a0 ...

A try catch block will not help at all. It doesn't catch anything. The log message before the parse prints and then the app crashes immediately.

I know there is some information about 0xebadde09 being related to hardware acceleration but I have disabled that as well (this is running in a background service anyway). Any hints on what to do or where to look would be appreciated. I've been trying many permutations with no luck.

  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?

nlohmann::json::parse a valid std::string.

  • What is the expected behavior?

Successful parse

  • And what is the actual behavior instead?

Crash

Using android studio with the -std=c++11 flag set.

  • Did you use a released version of the library or the version from the develop branch?

Released 3.6.1 and 3.7.3

N/A

@nlohmann
Copy link
Owner

nlohmann commented Apr 4, 2020

Do you have more information like a stack trace or example code including the input. Did you try to run the code with address sanitizer enabled or using Valgrind?

@nlohmann nlohmann added the state: needs more info the author of the issue needs to provide more details label Apr 4, 2020
@Burnrate
Copy link
Author

Burnrate commented Apr 4, 2020

This is the stack:

art_sigsegv_fault 0x0000007be641f864
art::FaultManager::HandleFault(int, siginfo*, void*) 0x0000007be641fd74
___lldb_unnamed_symbol24$$app_process64 0x0000005a4cba0dfc
<unknown> 0x0000007c6dcd1690
nlohmann::detail::json_sax_dom_parser<nlohmann::basic_json<std::__ndk1::map, std::__ndk1::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::__ndk1::allocator, nlohmann::adl_serializer> >::key(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >&) json.h:4530
bool nlohmann::detail::parser<nlohmann::basic_json<std::__ndk1::map, std::__ndk1::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::__ndk1::allocator, nlohmann::adl_serializer> >::sax_parse_internal<nlohmann::detail::json_sax_dom_parser<nlohmann::basic_json<std::__ndk1::map, std::__ndk1::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::__ndk1::allocator, nlohmann::adl_serializer> > >(nlohmann::detail::json_sax_dom_parser<nlohmann::basic_json<std::__ndk1::map, std::__ndk1::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::__ndk1::allocator, nlohmann::adl_serializer> >*) json.h:8862
nlohmann::detail::parser<nlohmann::basic_json<std::__ndk1::map, std::__ndk1::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::__ndk1::allocator, nlohmann::adl_serializer> >::parse(bool, nlohmann::basic_json<std::__ndk1::map, std::__ndk1::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::__ndk1::allocator, nlohmann::adl_serializer>&) json.h:8767
nlohmann::basic_json<std::__ndk1::map, std::__ndk1::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::__ndk1::allocator, nlohmann::adl_serializer>::parse(nlohmann::detail::input_adapter&&, std::__ndk1::function<bool (int, nlohmann::detail::parser<nlohmann::basic_json<std::__ndk1::map, std::__ndk1::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::__ndk1::allocator, nlohmann::adl_serializer> >::parse_event_t, nlohmann::basic_json<std::__ndk1::map, std::__ndk1::vector, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, bool, long, unsigned long, double, std::__ndk1::allocator, nlohmann::adl_serializer>&)>, bool) json.h:20750
..... (going into our stuff)

These are some of the values in the top level of the stack. Not really sure what is happening.
image

The string going in: "{"logically":{"value":"True"}}"

void Parameters::updateParameters(std::string newParams) {
    try {
    Log::v("PARAMETERS", "Parameter update %s, %s", newParams.c_str(), params.dump().c_str());
    // this will just be the variable name and the new value
    nlohmann::json newParamObject = nlohmann::json::parse(newParams);
...

Is the input being corrupted somehow? Not really sure if this is a json library problem but it keeps happening here.

@Burnrate
Copy link
Author

Burnrate commented Apr 6, 2020

Hi, we managed to isolate the json out of the crash. Something is happening at the same time as the json call and ruining the memory. Sorry for wasting time!

@Burnrate Burnrate closed this as completed Apr 6, 2020
@nlohmann nlohmann added solution: invalid the issue is not related to the library and removed state: needs more info the author of the issue needs to provide more details labels Apr 6, 2020
@YaminiT-94
Copy link

YaminiT-94 commented Jun 24, 2020

Hi how did you manage to resolve this issue? I am experiencing same issue on IOS. App crash is happening on specific network while parsing JSON. Exception not caught. Not entering in rescue block as well.

@Burnrate
Copy link
Author

@YaminiT-94 The information was being sent via udp and being received and sent down to c++ through jni. Once the data was processed it was sent off via an internal messaging system and then the local variables were deleted. There was an extra delete of a variable that just happened to always happen at the same time as the json data getting parsed as they were being executed on different threads.

Basically it was completely unrelated to the json and had to do with an extra delete causing a crash.

@YaminiT-94
Copy link

Hi, in my case application is crashing due to.poor network. In watchdog crash report I received excpetionas below:
Exception Type: EXC_CRASH (SIGKILL)

Exception Codes: 0x0000000000000000, 0x0000000000000000

Exception Note: EXC_CORPSE_NOTIFY

Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d

Termination Description: SPRINGBOARD, scene-update

As given solution in Apple documentation I cannot convert that synchronous call to asynchronous, neither can put on secondary thread. No use of increasing network timeout. Watchdog timeout is less than network timeout.

Any suggesstion/solution on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug solution: invalid the issue is not related to the library
Projects
None yet
Development

No branches or pull requests

3 participants