[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Crash in python bindings on windows (in apache)

From: Max Bowsher <maxb_at_ukf.net>
Date: 2005-10-16 16:27:19 CEST

David James wrote:
> On 10/14/05, Marc Haesen <Marc.Haesen@telindus.be> wrote:
>> The current python bindings crash in windows when used with viewcvs in
>> apache. The crash occurs when the apache server is restarted or stopped.
>>
>> It is the routine svn_swig_py_pool_destroyed that is crashing because
>> the function call apr_threadkey_private_get(&val, _saved_thread_key);
>> returns NULL as val. This is because the svn_swig_py_pool_destroyed is
>> not called from the same thread that created the pool.
>>
>> One possible fix is to replace the svn_swig_py_release_py_lock and
>> svn_swig_py_acquire_py_lock with the following two functions (only using
>> one thread_state for all threads):
>>
>> #ifdef ACQUIRE_PYTHON_LOCK
>> static PyThreadState *thread_state;
>> #endif
>>
>> void svn_swig_py_release_py_lock(void)
>> {
>> #ifdef ACQUIRE_PYTHON_LOCK
>> thread_state = PyEval_SaveThread();
>> #endif
>> }
>>
>> void svn_swig_py_acquire_py_lock(void)
>> {
>> #ifdef ACQUIRE_PYTHON_LOCK
>> PyEval_RestoreThread(thread_state);
>> #endif
>> }

> Thanks Marc! Max, Daniel, do you think it would be a good idea to
> change our bindings to use a single threadstate on Windows? (Using
> #ifdef WIN32 around Marc's code)

No!

First, *why* is the cross thread behaviour occurring?

Second, something as bizarre as saving the Python thread-local information
in one thread and restoring that info into a different thread seems just
plain *wrong*.

Max.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Oct 16 16:28:53 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.