From: SourceForge.net <no...@so...> - 2011-01-14 14:59:46
|
Bugs item #3119817, was opened at 2010-11-26 11:48 Message generated for change (Comment added) made by jimfcarroll You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3119817&group_id=1645 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: python Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Jim (jimfcarroll) Assigned to: Nobody/Anonymous (nobody) Summary: Uninitialization during Py_EndInterpreter causes later fail Initial Comment: This was accidentally added originally as a "Feature Request." Please delete Feature Request 3119739. This is complicated and has taken me several weeks and many hours to track down to a SWIG issue. Attached is a tar.gz file with commented code that reproduces the problem and a detailed README.txt file. The issue is related to running Python in an embedded manner using multiple threads with multiple calls to Py_NewInterpreter/Py_EndInterpreter. The first time a call to Py_EndInterpreter is executed the SWIG modules in other interpreters become completely invalid. This seems to even be the case for the *.py generated proxies. I've been baffled by what's going on but I managed to do the following things: 1) Reproduce the problem with a test case with minimal code (attached). 2) Verify it is not a Python bug by running this test case compiled as either a SWIG project OR with a hand coded python bridge. The handcoded python bridge works. The SWIG generated code does not. Please see the README.txt file in the attached for more details. This sample is meant to run on Linux and will run against SWIG 2.0.1. I have not tested it against an earlier release. ---------------------------------------------------------------------- >Comment By: Jim (jimfcarroll) Date: 2011-01-14 09:59 Message: I understand you guys are probably busy, and I'm willing to put more time into this trying to figure it out, but I was hoping to get some feedback from someone that knows the python generation system that might give me some insight or suggestions for avenues of investigation. If someone has time and wants to work with me on this, please let me know. I attached well documented code that will reproduce the problem and if you have other requirements, let me know and I'll do what I can. Thanks Jim ---------------------------------------------------------------------- Comment By: Jim (jimfcarroll) Date: 2010-11-27 08:48 Message: I tried a few more things. If you: 1) Add a couple more short run threads to main.cpp 2) Compile against the debug python (this requires compiling with -DPy_DEBUG) ... you can create an exception in which Python detects extra dereferences from SWIG (the reference count on some SWIG objects goes to -1). ---------------------------------------------------------------------- Comment By: Jim (jimfcarroll) Date: 2010-11-26 12:04 Message: One more note here. The SWIG compiled version will occasionally work so there's clearly a race condition somewhere. The HandCoded version always works. ---------------------------------------------------------------------- Comment By: Jim (jimfcarroll) Date: 2010-11-26 11:51 Message: URL to the "Feature Request" that should be deleted: https://sourceforge.net/tracker/index.php?func=detail&aid=3119739&group_id=1645&atid=351645 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3119817&group_id=1645 |