-
-
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
Segfault on direct initializing json object #973
Comments
What happens if you replace |
It's of type string; same behaviour when replaced with constant string (or other type or completely removed). I made further tests with various initialisations: json root_0 = {}; // working
json root_1 = {true}; // working
json root_2 = {10}; // working
json root_3 = {true, 10}; // working
json root_4 = {true, true}; // working
json root_5 = {11, 12}; // working
json root_6 = "{\"command\":\"test\"}"_json; // working
json root_7 = R"({"command": "test"})"_json; // working
json root_8 = {{13, 14}}; // not working
json root_9 = {"command"}; // not working
json root_10 = {"command", "test"}; // not working
json root_11 = {{"command", true}}; // not working
json root_12 = {{"command", 10}}; // not working
json root_13 = {{"command", "test"}}; // not working
json root_14 = json({{"command", "test"}}); // not working Seems to be a problem with non basic types passed without parsing. |
What is function |
Do you know a cross compiler for macOS so I could try to reproduce the issue? The code in #973 (comment) runs without issues on my machine... |
It's a server application which listens for json commands on tcp. The All command dependand functions have a similiar design, I'm using My tests (not very good ones as it shows) are working on both systems. Will try to compile my program for amd64 to see if the problem is platform or design dependand. Edit: no problem on amd64, but code is not 1:1 due to missing hardware when not running on embedded system I will also try to create small example code recreating my call chain to hopefully reproduce this crash. |
Unforunately I can't reproduce this in any other application. Only in my server application inside this specific type of function called inside a switch statement. When I replace all occurencies of |
I have no idea how to continue here. |
I will head back if I can contribute more information. I'm currently busy with other projects, when I have some time debugging, I dig deeper into it. |
Made some structural changes in my callchain, now the problem is gone: My switch statement is no longer directly calling the corresponding function, it now returns a std::function which is then called afterwards. Still no clue if my problem is related to this library or some other problem with my code. Seems to be a combination - since it worked in v2. But feel free to close this issue. |
Thanks for checking back! I shall close the issue. |
I'm currently updating from 2.x to 3.1.1: Now my default initialisation of json objects is causing a SEGFAULT:
Example:
This code is working fine:
I'm experiencing this in only one single way to call the containing function:
I'm using a command string parsed from an json object, and a std::map to map that string to an enumeration object, which I pass to a switch statement to determine which function to be called.
If I skip the switch statement, and determine the calling of the function by directly comparing the command string, it won't crash.
I'm using gcc 4.9.2 with cross compiling to armv7.
Heres a backtrace after crashing:
The text was updated successfully, but these errors were encountered: