[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: Marc Haesen <Marc.Haesen_at_telindus.be>
Date: 2005-10-17 08:52:04 CEST

The reason is that the svn_swig_py_pool_destroyed is called from the
apr_terminate function call which is called from apache after all the
other threads are terminated.

If there is a way in apr to call the svn_swig_py_pool_destroyed when the
thread that created the pool terminates, the problem is solved to.

Regards,
Marc

-----Original Message-----
From: Max Bowsher [mailto:maxb@ukf.net]
Sent: Sunday, October 16, 2005 16:27
To: David James; Marc Haesen
Cc: dev@subversion.tigris.org; Daniel L. Rall
Subject: Re: Crash in python bindings on windows (in apache)

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 Mon Oct 17 08:52:54 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.