-
Notifications
You must be signed in to change notification settings - Fork 823
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
conversion from string to JSON is not multithread-safe #675
Comments
The cause is that the conversion from string to double, in strconv.c: So, in thread1 with its English locale, In thread1, when |
The fix is to use |
|
Thanks! Fixed in #677. |
When two different threads use
json_loads
to convert a string to a JSON object, they can disturb each other: one of the threads may run into an assertion failure and crash the program.How to reproduce:
On a system with glibc, compile and run the following program
foo.c
:Like this:
Here is the gdb stack trace:
Note: When one of the
pthread_create
lines is commented out, such that only one thread is created, the program runs fine. Only when bothpthread_create
lines are enabled, does the program crash. This proves that there is an interaction between the threads.Note: The test program fulfils the rules documented in https://jansson.readthedocs.io/en/latest/threadsafety.html :
json_t
objects are private to each of the threads.setlocale
.The text was updated successfully, but these errors were encountered: