#20 Module crashes "Fatal Python error: ceval: tstate mix-up"

closed-fixed
nobody
None
5
2009-11-13
2009-01-28
Maksym Sobolyev
No

Hi,

In a heavily threaded applicaiton that uses the package from more than one thread at a time, the pyOpenSSL 0.8 often makes Python 2.5 interpreter crash with the following errror message:

Fatal Python error: ceval: tstate mix-up
Abort trap: 6 (core dumped)

We have test program that crashes reliably in no time here.

There are other reports of the same issue:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/ab1317191a8182e5

Investigation revealed that it is caused by the mis-use of the key to store per-thread context. Instead, it's suggested to save the context in per-instance private data. It is safe to do this, since one object instance cannot be used in separate threads at the very same time due to SSL_CTX and libopenssl API in general not being thread-friendly. Therefore, external locking at python level is required to properly serialize access to methods of the same instance anyway. But this patch makes it safe to use different instances in different threads at the same time.

Proposed patch is attached. The patch also cleans up some of the old, now unused code.

Thanks!

Discussion

  • Proposed patch.

     
    Attachments
  • Jp Calderone
    Jp Calderone
    2009-11-13

    This was fixed in 0.9. Please use the Launchpad tracker if you have further issues. Thanks.

     
  • Jp Calderone
    Jp Calderone
    2009-11-13

    • status: open --> closed-fixed