-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
cJSON is not multithreading safe #314
Comments
My suggestion to solve this would be to add the following new functions to the API whenever the next API change is:
With the following semantics: if I would submit a PR, but I'm not sure if you are okay with API changes in the next release |
Thank you for the fast reply, at the moment I deleted all references to the global error because I don't use it, but it would be nice to have it in the default implementation, so I don't have to patch it every time I update cjson to latest version. I am ok with the API modifications in the next release, as I link cjson statically. Thanks a lot! |
... The tone of your reply concerns me, as it seems you think I am in charge here. To be clear, I was speaking to the maintainer. I have no power here, was simply giving suggestions on a fix for the issue. |
Oh sorry, I thought you were one of the maintainers :-) |
No problem, just wanted to make sure you weren't disappointed later on xD |
@tawmoto Please take a look at the README, there is a section about this issue: https://github.com/DaveGamble/cJSON#thread-safety Essentially if you |
Thank you, I know it's safe because I don't use that function, as I mentioned before. But the helgrind still is very noisy, the only possibility is to patch the code or add an exception to helgrind. |
For the time being that will probably be the only way to silence it. The internals of cJSON are already prepared to drop all global state once a new API comes around, but since I haven't found a lot of time to work on anything other than bugfixes it is not certain when that will be. |
Hello,
I am trying to do some serialization in multiple threads but helgrind complains a lot, because of the above line.
Perhaps adding a compilation flag which disables this static global can be useful, because not everyone uses cJSON_GetErrorPtr function. The only solution as the moment is to patch the code internally before compiling it.
Thanks
The text was updated successfully, but these errors were encountered: