Anyone depending on M2Crypto and Python < 2.3?

Heikki Toivonen <[email protected]>
Newsgroups gmane.comp.python.cryptography
Message-ID <[email protected]>
The reason I am asking is because of the crash bugs with the callbacks
used in M2Crypto. For example, I can not use custom SSL verification
callback at all, nor dh param generators with callbacks.

For example: https://bugzilla.osafoundation.org/show_bug.cgi?id=3120

A colleague spotted a problem with the way M2Crypto currently tries to
deal with threads and GIL (it doesn't), and suggested a way to fix this
using PyGILState_Ensure/PyGILState_Release. I've confirmed these make
the crashes go away and the callbacks to work. However, these Python C
API functions were introduced in 2.3.

I could make an isolated change to just the callbacks functions, and
ifdef things so that callbacks would be just as broken as they are now
for Python < 2.3, and make them work for later Python versions.

Or I could do a complete overhaul which would make M2Crypto depend on
Python >= 2.3. I actually prefer this solution so hoping nobody is
depending on old Python. Here's how:

First:

%exception {

    PyThreadState *state = PyEval_SaveThread();
    $action
    PyEval_RestoreThread(state);
}

Then get rid of all the existing SaveThread/RestoreThread code.

Then bracket all code that calls Python functions with
PyGILState_Ensure()/PyGILState_Release().

--
  Heikki Toivonen
signature.asc (application/pgp-signature, 249 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFCl7UGb8x8KoP+JuwRAh8+AKCK0tGX1vwsLDii28oX03+Of1Pu2QCeIVsC
euFs/pOBJFE98ZjYnQPGtSk=
=yW2q
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.