From: SourceForge.net <no...@so...> - 2010-09-27 01:21:10
|
Bugs item #3075178, was opened at 2010-09-25 10:56 Message generated for change (Settings changed) made by olly You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3075178&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: [Python] Dealloc of statically assigned data Initial Comment: This took me a while to track down. In short, if you use Python embedded and use SWIG to join the native side to python, and you use Py_NewInterpreter and Py_EndInterpreter repeatedly (as you must in more sophisticated mutithreaded programs), you will eventually crash. This is because in the generated method "SWIG_Python_DestroyModule" calls Py_DECREF prior to exiting on SWIG_This(). SWIG_This() returns a static pointer that, in C++, is initialized ONLY ONCE. The Py_DECREF results in the deallocation of the 'SWIG_this' object but the static pointer in the SWIG_This() method remains pointing to the space. The NEXT time the module is loaded through another Py_NewInterpreter and call to the init_[moduleName] the value of this freed memory is then used. ---------------------------------------------------------------------- >Comment By: Olly Betts (olly) Date: 2010-09-27 14:21 Message: Might resetting the static pointer to NULL fix this? If so could you test that and submit a patch if it work? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3075178&group_id=1645 |
From: SourceForge.net <no...@so...> - 2010-09-27 01:21:10
|
Bugs item #3075178, was opened at 2010-09-25 10:56 Message generated for change (Comment added) made by olly You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3075178&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: [Python] Dealloc of statically assigned data Initial Comment: This took me a while to track down. In short, if you use Python embedded and use SWIG to join the native side to python, and you use Py_NewInterpreter and Py_EndInterpreter repeatedly (as you must in more sophisticated mutithreaded programs), you will eventually crash. This is because in the generated method "SWIG_Python_DestroyModule" calls Py_DECREF prior to exiting on SWIG_This(). SWIG_This() returns a static pointer that, in C++, is initialized ONLY ONCE. The Py_DECREF results in the deallocation of the 'SWIG_this' object but the static pointer in the SWIG_This() method remains pointing to the space. The NEXT time the module is loaded through another Py_NewInterpreter and call to the init_[moduleName] the value of this freed memory is then used. ---------------------------------------------------------------------- >Comment By: Olly Betts (olly) Date: 2010-09-27 14:21 Message: Might resetting the static pointer to NULL fix this? If so could you test that and submit a patch if it work? ---------------------------------------------------------------------- Comment By: Olly Betts (olly) Date: 2010-09-27 14:21 Message: Might resetting the static pointer to NULL fix this? If so could you test that and submit a patch if it work? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3075178&group_id=1645 |
From: SourceForge.net <no...@so...> - 2010-09-27 12:09:53
|
Bugs item #3075178, was opened at 2010-09-24 17:56 Message generated for change (Comment added) made by jimfcarroll You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3075178&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: [Python] Dealloc of statically assigned data Initial Comment: This took me a while to track down. In short, if you use Python embedded and use SWIG to join the native side to python, and you use Py_NewInterpreter and Py_EndInterpreter repeatedly (as you must in more sophisticated mutithreaded programs), you will eventually crash. This is because in the generated method "SWIG_Python_DestroyModule" calls Py_DECREF prior to exiting on SWIG_This(). SWIG_This() returns a static pointer that, in C++, is initialized ONLY ONCE. The Py_DECREF results in the deallocation of the 'SWIG_this' object but the static pointer in the SWIG_This() method remains pointing to the space. The NEXT time the module is loaded through another Py_NewInterpreter and call to the init_[moduleName] the value of this freed memory is then used. ---------------------------------------------------------------------- >Comment By: Jim (jimfcarroll) Date: 2010-09-27 07:09 Message: Yes. That's what I did to fix it. The problem is, the scope of the static variable is inside of the function SWIG_This(). I needed to move the variable to the file scope. The patch to do this is attached. I would have attached it originally but I wasn't sure if that's the way you wanted it fix. You should Note that this fix is not thread safe - but according to the manual you aren't supposed to be initializing and deinitializing from multiple threads anyway. I synchronized access to the initialization routines. I don't think this matters when running from the scripting language interpreter itself but please verify my reasoning before accepting the patch. Thanks ---------------------------------------------------------------------- Comment By: Olly Betts (olly) Date: 2010-09-26 20:21 Message: Might resetting the static pointer to NULL fix this? If so could you test that and submit a patch if it work? ---------------------------------------------------------------------- Comment By: Olly Betts (olly) Date: 2010-09-26 20:21 Message: Might resetting the static pointer to NULL fix this? If so could you test that and submit a patch if it work? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3075178&group_id=1645 |
From: SourceForge.net <no...@so...> - 2010-09-27 12:31:15
|
Bugs item #3075178, was opened at 2010-09-24 17:56 Message generated for change (Comment added) made by jimfcarroll You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3075178&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: [Python] Dealloc of statically assigned data Initial Comment: This took me a while to track down. In short, if you use Python embedded and use SWIG to join the native side to python, and you use Py_NewInterpreter and Py_EndInterpreter repeatedly (as you must in more sophisticated mutithreaded programs), you will eventually crash. This is because in the generated method "SWIG_Python_DestroyModule" calls Py_DECREF prior to exiting on SWIG_This(). SWIG_This() returns a static pointer that, in C++, is initialized ONLY ONCE. The Py_DECREF results in the deallocation of the 'SWIG_this' object but the static pointer in the SWIG_This() method remains pointing to the space. The NEXT time the module is loaded through another Py_NewInterpreter and call to the init_[moduleName] the value of this freed memory is then used. ---------------------------------------------------------------------- >Comment By: Jim (jimfcarroll) Date: 2010-09-27 07:31 Message: One more note ... this also affects the 1.3.x versions. I'm not sure if you're continuing to maintain them both or not but if so a similar thing should be done there. ---------------------------------------------------------------------- Comment By: Jim (jimfcarroll) Date: 2010-09-27 07:09 Message: Yes. That's what I did to fix it. The problem is, the scope of the static variable is inside of the function SWIG_This(). I needed to move the variable to the file scope. The patch to do this is attached. I would have attached it originally but I wasn't sure if that's the way you wanted it fix. You should Note that this fix is not thread safe - but according to the manual you aren't supposed to be initializing and deinitializing from multiple threads anyway. I synchronized access to the initialization routines. I don't think this matters when running from the scripting language interpreter itself but please verify my reasoning before accepting the patch. Thanks ---------------------------------------------------------------------- Comment By: Olly Betts (olly) Date: 2010-09-26 20:21 Message: Might resetting the static pointer to NULL fix this? If so could you test that and submit a patch if it work? ---------------------------------------------------------------------- Comment By: Olly Betts (olly) Date: 2010-09-26 20:21 Message: Might resetting the static pointer to NULL fix this? If so could you test that and submit a patch if it work? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3075178&group_id=1645 |
From: SourceForge.net <no...@so...> - 2010-09-27 15:25:52
|
Bugs item #3075178, was opened at 2010-09-25 10:56 Message generated for change (Comment added) made by olly You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3075178&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: [Python] Dealloc of statically assigned data Initial Comment: This took me a while to track down. In short, if you use Python embedded and use SWIG to join the native side to python, and you use Py_NewInterpreter and Py_EndInterpreter repeatedly (as you must in more sophisticated mutithreaded programs), you will eventually crash. This is because in the generated method "SWIG_Python_DestroyModule" calls Py_DECREF prior to exiting on SWIG_This(). SWIG_This() returns a static pointer that, in C++, is initialized ONLY ONCE. The Py_DECREF results in the deallocation of the 'SWIG_this' object but the static pointer in the SWIG_This() method remains pointing to the space. The NEXT time the module is loaded through another Py_NewInterpreter and call to the init_[moduleName] the value of this freed memory is then used. ---------------------------------------------------------------------- >Comment By: Olly Betts (olly) Date: 2010-09-28 04:25 Message: Thanks for the patch - I'll take a look. 2.0.0 is really just what would have been 1.3.41, but with the version number bumped because of the licensing change (and because it was about time to declare things as stable anyway). So we wouldn't maintain 1.3.x other than by releasing 2.0.y. ---------------------------------------------------------------------- Comment By: Jim (jimfcarroll) Date: 2010-09-28 01:31 Message: One more note ... this also affects the 1.3.x versions. I'm not sure if you're continuing to maintain them both or not but if so a similar thing should be done there. ---------------------------------------------------------------------- Comment By: Jim (jimfcarroll) Date: 2010-09-28 01:09 Message: Yes. That's what I did to fix it. The problem is, the scope of the static variable is inside of the function SWIG_This(). I needed to move the variable to the file scope. The patch to do this is attached. I would have attached it originally but I wasn't sure if that's the way you wanted it fix. You should Note that this fix is not thread safe - but according to the manual you aren't supposed to be initializing and deinitializing from multiple threads anyway. I synchronized access to the initialization routines. I don't think this matters when running from the scripting language interpreter itself but please verify my reasoning before accepting the patch. Thanks ---------------------------------------------------------------------- Comment By: Olly Betts (olly) Date: 2010-09-27 14:21 Message: Might resetting the static pointer to NULL fix this? If so could you test that and submit a patch if it work? ---------------------------------------------------------------------- Comment By: Olly Betts (olly) Date: 2010-09-27 14:21 Message: Might resetting the static pointer to NULL fix this? If so could you test that and submit a patch if it work? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3075178&group_id=1645 |
From: SourceForge.net <no...@so...> - 2010-10-01 04:03:38
|
Bugs item #3075178, was opened at 2010-09-25 10:56 Message generated for change (Comment added) made by olly You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3075178&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: Closed >Resolution: Accepted Priority: 5 Private: No Submitted By: Jim (jimfcarroll) Assigned to: Nobody/Anonymous (nobody) Summary: [Python] Dealloc of statically assigned data Initial Comment: This took me a while to track down. In short, if you use Python embedded and use SWIG to join the native side to python, and you use Py_NewInterpreter and Py_EndInterpreter repeatedly (as you must in more sophisticated mutithreaded programs), you will eventually crash. This is because in the generated method "SWIG_Python_DestroyModule" calls Py_DECREF prior to exiting on SWIG_This(). SWIG_This() returns a static pointer that, in C++, is initialized ONLY ONCE. The Py_DECREF results in the deallocation of the 'SWIG_this' object but the static pointer in the SWIG_This() method remains pointing to the space. The NEXT time the module is loaded through another Py_NewInterpreter and call to the init_[moduleName] the value of this freed memory is then used. ---------------------------------------------------------------------- >Comment By: Olly Betts (olly) Date: 2010-10-01 17:03 Message: Applied to trunk in r12235, so should be in 2.0.1. I removed the SWIG_STATIC_POINTER() use, which isn't needed now. It does nothing with C++ but stops the code compiling with C. ---------------------------------------------------------------------- Comment By: Olly Betts (olly) Date: 2010-09-28 04:25 Message: Thanks for the patch - I'll take a look. 2.0.0 is really just what would have been 1.3.41, but with the version number bumped because of the licensing change (and because it was about time to declare things as stable anyway). So we wouldn't maintain 1.3.x other than by releasing 2.0.y. ---------------------------------------------------------------------- Comment By: Jim (jimfcarroll) Date: 2010-09-28 01:31 Message: One more note ... this also affects the 1.3.x versions. I'm not sure if you're continuing to maintain them both or not but if so a similar thing should be done there. ---------------------------------------------------------------------- Comment By: Jim (jimfcarroll) Date: 2010-09-28 01:09 Message: Yes. That's what I did to fix it. The problem is, the scope of the static variable is inside of the function SWIG_This(). I needed to move the variable to the file scope. The patch to do this is attached. I would have attached it originally but I wasn't sure if that's the way you wanted it fix. You should Note that this fix is not thread safe - but according to the manual you aren't supposed to be initializing and deinitializing from multiple threads anyway. I synchronized access to the initialization routines. I don't think this matters when running from the scripting language interpreter itself but please verify my reasoning before accepting the patch. Thanks ---------------------------------------------------------------------- Comment By: Olly Betts (olly) Date: 2010-09-27 14:21 Message: Might resetting the static pointer to NULL fix this? If so could you test that and submit a patch if it work? ---------------------------------------------------------------------- Comment By: Olly Betts (olly) Date: 2010-09-27 14:21 Message: Might resetting the static pointer to NULL fix this? If so could you test that and submit a patch if it work? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3075178&group_id=1645 |