[C++-sig] Details of Boost.Python Py_Finalize issue? (original) (raw)

Haoyu Bai divinekid at gmail.com
Sun Aug 2 17:44:22 CEST 2009


Hello,

As suggested by Stefan, I'm looking into the Boost.Python Py_Finalize issue. According to Boost.Python manual, the issue is:

"Currently Boost.Python has several global (or function-static) objects whose existence keeps reference counts from dropping to zero until the Boost.Python shared object is unloaded. This can cause a crash because when the reference counts do go to zero, there's no interpreter. In order to make it safe to call PyFinalize() we must register an atexit routine which destroys these objects and releases all Python reference counts so that Python can clean them up while there's still an interpreter."

However, until now I can't reproduce the problem. I tried to modify the exec.cpp in BPL test suite to call Py_Initialize and Py_Finalize many times in a loop ( http://pastebin.com/f77279354 ), and also tried examples provided in some report like this: http://d.hatena.ne.jp/floth/20090525/1243247990 . But neither of them can cause a crash or observable memory leak on my machine (Arch Linux with gcc 4.4, Python 2.6 and Boost 1.39).

I also checked BPL source code, but can't spot out any suspicious code that may cause problems.

So could anyone share your experience with this issue, provide some test case or anymore information about this issue? I will try to solve it.

Thank you!

-- Haoyu Bai School of Computing, National University of Singapore.



More information about the Cplusplus-sig mailing list