[C++-sig] Details of Boost.Python Py_Finalize issue?

Ravi lists_ravi at lavabit.com
Fri Aug 7 05:16:13 CEST 2009


On Thursday 06 August 2009 22:16:59 Haoyu Bai wrote:
> > Test 1 (to check registry operation):
> > 1. Use an example which embeds (not extends) python.
> > 2. Register a type X to be converted to C++ type XC.
> > 3. Perform some operations to verify that step 2 works.
> > 4. Call PyFinalize.
> > 5. Restart python vising PyInit...
> > 6. Check that X does not convert to XC.
> >
> > Test 2 (to check object cleanup):
> > 1. Hold weak pointers to some shared_ptr<T> objects exposed to python.
> > 2. Call PyFinalize.
> > 3. Ensure that all the weak_ptrs point to deleted objects.
> >
> I have the attached file to check the two test cases you mentioned, or
> see it at here: http://pastebin.org/7108
>
> The test #1 failed. Registered converters are not cleaned up during
> Py_Finalize. But test #2 not fail, shared_ptr object is properly
> destroyed.

You rock. There are more cases where data ought to be cleaned up, but I forget 
now. Let me look at some old custom converter code this weekend before I come 
up with more tests.

> I think the registration issue is not hard to fix. But is the "crash"
> mentioned in BPL manual still valid? We still can't produce any crash.

The only way I can think of for this to happen is if boost.python holds some 
reference to an object held by the python interpreter before PyFinalize was 
called. The only candidate I could find is the fundamental PyTypeObject used 
by boost.python but nothing popped out on a cursory look, but then I doubt 
anyone can find bugs in Dave's code upon cursory examination :-)

I am not sure that I can spend enough time on this prior to the end of your 
GSOC period. Apologies.

Regards,
Ravi



More information about the Cplusplus-sig mailing list