-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
svm_train() in svmutil.py is not thread-safe #167
Comments
There are a few other places where libsvm isn't thread safe.. Some are
because of historical reasons. We may handle some important ones in the
near future, though the plan is uncertain yet..
…On 2020-04-30 19:03, wyykak wrote:
To be more exact, _svm_set_print_string_function()_ in svm.cpp is not
thread-safe, as it modifies a global function pointer
_svm_print_string_. If you call _svm_train()_ in multiple Python
threads with '-q' option, it will try to convert _print_null()_ to a
C-style function pointer and assign it to _svm_print_string_ in order
to suppress the output.
However, the function pointer generated each time seems to point to
different addresses, which makes it possible to corrupt
_svm_print_string_ and crash the program.
I suggest to make the printing function pointer independent in
different function calls. A global print option is neither thread-safe
nor practical.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub [1], or unsubscribe
[2]. [ { ***@***.***": "http://schema.org", ***@***.***": "EmailMessage",
"potentialAction": { ***@***.***": "ViewAction", "target":
"#167", "url":
"#167", "name": "View Issue" },
"description": "View this Issue on GitHub", "publisher": { ***@***.***":
"Organization", "name": "GitHub", "url": "https://github.com" } } ]
Links:
------
[1] #167
[2]
https://github.com/notifications/unsubscribe-auth/ABI3BHR7IMVMNRPIPF4IARLRPFLH7ANCNFSM4MVNGHBA
|
Thanks for your reply! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To be more exact, svm_set_print_string_function() in svm.cpp is not thread-safe, as it modifies a global function pointer svm_print_string. If you call svm_train() in multiple Python threads with '-q' option, it will try to convert print_null() to a C-style function pointer and assign it to svm_print_string in order to suppress the output.
However, the function pointer generated each time seems to point to different addresses, which makes it possible to corrupt svm_print_string and crash the program.
I suggest to make the printing function pointer independent in different function calls. A global print option is neither thread-safe nor practical.
The text was updated successfully, but these errors were encountered: