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
Call CRYPTO_set_locking_callback #352
Conversation
Do we want a unit test that spawn a few threads and tries to cause bad things to happen? It usually crashes pretty fast on Linux if things aren't working but @reaperhulk said it didn't crash on Windows anyway :-/ |
Can one of the admins verify this patch? |
1 similar comment
Can one of the admins verify this patch? |
add to whitelist |
I'd definitely like to see a test, but even with #330 it usually takes 20-30 seconds to crash on OS X. We could create a mark for slow tests if we wanted to start splitting this sort of thing out from the primary test suite? Would need to create a jenkins job to run the slow tests exclusively then... |
Test FAILed. |
Test FAILed. |
Test PASSed. |
I think I can safely get rid of the sem_init version and just use the pthread_mutex on Linux now but I'm not really sure why CPython and PyPy both have implementations for each of them. |
Test FAILed. |
Test FAILed. |
I've added attempting to import _ssl to get Python to set it's handler. This also conditionally sets our handler if Python didn't for some reason. I'm not sure this buys us anything but making things more complex. _ssl won't reinit it's lock handler ever after the first import so simply immediately overwriting it's handler is quite safe. I guess we save |
Test FAILed. |
Test FAILed. |
Test FAILed. |
Test PASSed. |
Test PASSed. |
FYI this need to be rebased on master. |
Test PASSed. |
Test PASSed. |
Did you get anywhere with using this in pyOpenSSL @exarkun ? |
Given pyca/pyopenssl#7 I believe this should be high-priority. |
So that we actually get some thread safety
because their sem_init is implemented as exit(1)
pthread_mutex works on Linux anyway and isn't obviously any better at coping with fork() issues.
Probably not particularly great at finding issues on all platforms. Notably Windows doesn't seem to crash without it anyway.
Adds quite a bit of complexity, might be better to set ours unconditionally but still import _ssl so that it doesn't overwrite ours at some point later.
Makes it a bit easier to read.
Test PASSed. |
Test PASSed. |
Latest build returns these errors when attempting to compile on windows: http://bpaste.net/show/prfcOee90CjIL85YbuCz/ |
Weird given that it worked before. I think I know what's wrong though, will sort it out once I get a Windows VM to play with :) |
Closing in favor of #492 |
complete the flake8-ification of this file
So that we actually get some thread safety.
The cross platform locking stuff is based on the PyPy code and is entirely untested on Windows. This does fix the crash in my test case described in #330 on Linux.