-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
segmentation fault on json-c parsing methods in cross compiled target #705
Comments
It's going to be pretty hard to suggest anything without some more details. Can you load the core dump in a debugger and see where it crashed? |
Unfortunately, that doesn't show much and I even re-compiled with the -g option.
I'm thinking the toolchainfile isn't enough to make CMake find target includes and libs and it's using the systems instead. |
GDB didn't show much because it failed to load/locate your compiled json_parse executable (and hence the debug symbols). Probably best to copy the core into the same directory as the executable for now.
Anyhow, with only one frame apparently on the stack it probably failed quite early. Good luck! |
Hey thanks for the reply and patience. Found gdbserver for this arch and trying to use it, still don't know what I am doing with gdb though. Changed the compilation a bit but the error is still the same. But here it is: Remote device:
My machine:
Seems like the problem is actually in libc from this call?
Thanks |
Looks like it crashed in duplocale() as you mentioned. You could try the patch from FreeBSD in the issue below that should enable an alternate code path in the json-c library: If that doesn't help, you can probably modify the patch to disable HAVE_SETLOCALE as well. You'll have to be the judge of whether locale support matters for you. |
Greedily for now I just removed the parts in json_tokener.c that are executed if HAVE_SETLOCALE and HAVE_USELOCALE are set, and json_parse now works and my code as well! Thx Tbh I don't understand why they are executed in the first place, the patch seems to act on config.h which I guess is after the cmake command, but these variables aren't set here (there is 1 in CMakeCache maybe that's it?):
I'd expect a 1 to follow the define statements on config.h Let me know if you want something from me such as running the scripts suggested in #668 to check locale behavior. Thank you Edit: edited out lines with LOCALE string in json-c/cmake/config.h.in and it works. |
Those variables are set in config.h. It doesn't matter what value those preprocessor variables are set to, just that they're set at all, because they're checked with simple #ifdefs in the code. The easiest quick patch it probably to comment out the check_include_file lines in CMakeLists.txt that refer to locale.h and xlocale.h. Without the locale handling code you'll need to make sure to run your program in the "C" locale. As for what change to commit, I think we'll need to have the cmake checks actually run a program that uses duplocale, and see if it works or crashes. |
Awesome thanks! If you want me to run anything let me know. |
Actually, we can't run a program that uses duplocale in this case, because you're cross-compiling. |
… because its duplocale() function (intentionally) crashes.
Commit 253a5fa should address this, please re-open if it doesn't work for you. |
Hi,
I'm trying to embed our software which uses json-c on a MIPS 32 target. Methods to build JSON such as
json_object_new_object()
work fine but parsing with for examplejson_tokener_parse()
seg faults in this target. I think there is a problem with our cross-compilation because it works on other platforms, so any help here is much appreciated.To simplify things I'm focusing on the app provided json_parse, which also seg faults, so I'm thinking if json_parse works so will our code. On the target:
From what I understood running the same thing on my machine the output should be something like this:
file utility output on the target:
I'm building for the target from the master specifying this toolchain file:
So basically I run:
$ cmake -DCMAKE_TOOLCHAIN_FILE="/usr/src/toolchainfile.cmake" ../json-c
on json-c-build folder, and this is the compiler I'm using:
Thank you
The text was updated successfully, but these errors were encountered: