You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just wanted to share this with the community. I do not see this as a bug or real issue. More a project related issue, but it took me several hours to find out what was the cause. You can probably directly close the issue. But this way other people with same kind of issue could have an idea what to look for
(i had a hard time to find info on segfault with the lib on the internet; which is a compliment :-))
I had a project that required to a #pragma pack (push, 1) in an include file for one of my structures.
This was incompatible with this json module and resulted in a segfault when calling parse()
Pretty hard to find the issue. I was thinking about os related issues, memory leak in my program, compiler options, ... none of that helped to solve the issue.
Wrote another small program that parsed json and this worked fine. So rules out all of these ideas.
Finally found out by copying some json parsing code in my project's main() function and comment all other code parts and includes. By uncommenting and re-including step by step, I drilled down to this #pragma directive that was the root cause.
Probably it's better not to use too much of this pragma pack (push,1) stuff anyway, or to normalize after the particular structure that needs it... lesson learned :-)
Reproduction steps
add a structure that need special packing and add "#prama pack (push, 1)" in front of it
Expected vs. actual results
no segfault when calling parse()
Minimal code example
Not applicable.
Error messages
segfault 11
Compiler and operating system
g++ / Mint 21.1 - 64bit
Library version
initially happens on 3.10.5
Validation
The bug also occurs if the latest version from the develop branch is used.
Were you using this library in multiple files and only doing the pragma in some of them? That would definitely cause ODR (one definition rule) failures, as you would get different declarations of the same structure in different translation units (files), which is not allowed by the standard, but isn't required to be diagnosed.
Did they all include the two headers in the same order? The pragma takes effect from that point forward, so if some files included the json header first, then they wouldn't be affected by it.
Description
Hi,
I just wanted to share this with the community. I do not see this as a bug or real issue. More a project related issue, but it took me several hours to find out what was the cause. You can probably directly close the issue. But this way other people with same kind of issue could have an idea what to look for
(i had a hard time to find info on segfault with the lib on the internet; which is a compliment :-))
I had a project that required to a #pragma pack (push, 1) in an include file for one of my structures.
This was incompatible with this json module and resulted in a segfault when calling parse()
Pretty hard to find the issue. I was thinking about os related issues, memory leak in my program, compiler options, ... none of that helped to solve the issue.
Wrote another small program that parsed json and this worked fine. So rules out all of these ideas.
Finally found out by copying some json parsing code in my project's main() function and comment all other code parts and includes. By uncommenting and re-including step by step, I drilled down to this #pragma directive that was the root cause.
Probably it's better not to use too much of this pragma pack (push,1) stuff anyway, or to normalize after the particular structure that needs it... lesson learned :-)
Reproduction steps
add a structure that need special packing and add "#prama pack (push, 1)" in front of it
Expected vs. actual results
no segfault when calling parse()
Minimal code example
Error messages
Compiler and operating system
g++ / Mint 21.1 - 64bit
Library version
initially happens on 3.10.5
Validation
develop
branch is used.The text was updated successfully, but these errors were encountered: