-
Notifications
You must be signed in to change notification settings - Fork 185
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
rb_str_resize(Qfalse, 0)
with NKF and without C extensions lock
#3625
Comments
It seems to me all the global variables could lead to such issues: truffleruby/src/main/c/nkf/nkf.c Lines 32 to 38 in 938589f
So all these variables probably should be passed everywhere (as a struct?). They are used only in this file so it doesn't seem a big effort to fix. Does it makes sense to do it? |
The problem is e.g. |
Created a PR ruby/nkf#19 |
Found by @mohamedhafez and reported on Slack:
So this must be a call to
rb_str_resize(str, 0)
withstr=0
but of course it shouldn't be 0.Looking at NKF sources, there is a single call to
rb_str_resize
:truffleruby/src/main/c/nkf/nkf.c
Line 47 in 938589f
result
is a global variable 😨truffleruby/src/main/c/nkf/nkf.c
Line 40 in 938589f
truffleruby/src/main/c/nkf/nkf.c
Lines 164 to 168 in 938589f
So that is very likely the issue.
One solution is to use a native thread-local variable instead.
Or pass it as an extra parameter but that would require touching more of the upstream nkf code.
Or, always use the C extensions lock/a lock for NKF.
The text was updated successfully, but these errors were encountered: