python-spake2 icon indicating copy to clipboard operation
python-spake2 copied to clipboard

Thread-safety & Locking

Open jtdoepke opened this issue 8 years ago • 2 comments

I encountered a race condition while running wormhole receive where one thread called spake2.spake2.SPAKE2_Symmetric.finish() before spake2.spake2.SPAKE2_Symmetric.start() was complete. Now I'm having trouble recreating it in wormhole (of course :smile: ), but easy enough fix: this PR adds locking to the start and finish methods of _SPAKE2_Base. It also upgrades the included version of six to 1.11.0 because there was also a thread-safety bug in six<=1.9.0.

jtdoepke avatar Oct 12 '17 14:10 jtdoepke

Coverage Status

Changes Unknown when pulling 84c7d5c8f2e9fb8d96660c20b58416a56b9640ff on jtdoepke:locking into ** on warner:master**.

coveralls avatar Oct 12 '17 15:10 coveralls

warner/magic-wormhole#280 sounds like it addressed the same bug, so I guess this PR is no longer necessary.

jtdoepke avatar Mar 07 '18 15:03 jtdoepke

If there is (still) interest in this, please re-open without the "six" changes.

For threaded users, it might be nicer overall to have a "locked" version, so that async or other single-threaded users don't pay any penalty for the lock. (Looking quickly at the referenced magic-wormhole fix it seems the real culprit was "using Twisted APIs wrong" and not necessarily a lock issue here?)

meejah avatar Aug 06 '24 23:08 meejah