[110495] trunk/dports/python/py-zeroc-ice34

blair at macports.org blair at macports.org
Sat Aug 31 11:08:24 PDT 2013


Revision: 110495
          https://trac.macports.org/changeset/110495
Author:   blair at macports.org
Date:     2013-08-31 11:08:24 -0700 (Sat, 31 Aug 2013)
Log Message:
-----------
py-zeroc-ice34: fix core dump after Python 2.7.4 upgrade.

The unit tests used to successfully pass.

$ port -v test py27-zeroc-ice34
...
...
*** running tests 3/25 in /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py-zeroc-ice34/py27-zeroc-ice34/work/Ice-3.4.2/py/test/Ice/adapterDeactivation
*** configuration: Default 
*** test started: 08/31/13 11:02:23
starting Server.py... ok
starting Client.py... ok
testing stringToProxy...  ok
testing checked cast...  ok
creating/destroying/recreating object adapter...  ok
creating/activating/deactivating object adapter in one operation...  ok
deactivating object adapter in the server...  ok
testing whether server is gone...  ok
unexpected exit status: expected: 0, got -11
Traceback (most recent call last):
  File "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py-zeroc-ice34/py27-zeroc-ice34/work/Ice-3.4.2/py/test/Ice/adapterDeactivation/run.py", line 23, in <module>
    TestUtil.clientServerTest()
  File "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py-zeroc-ice34/py27-zeroc-ice34/work/Ice-3.4.2/scripts/TestUtil.py", line 1185, in clientServerTest
    clientProc.waitTestSuccess()
  File "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py-zeroc-ice34/py27-zeroc-ice34/work/Ice-3.4.2/scripts/Expect.py", line 540, in waitTestSuccess
    test(self.exitstatus, exitstatus)
  File "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py-zeroc-ice34/py27-zeroc-ice34/work/Ice-3.4.2/scripts/Expect.py", line 525, in test
    assert False
AssertionError
('test in /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py-zeroc-ice34/py27-zeroc-ice34/work/Ice-3.4.2/py/test/Ice/adapterDeactivation failed with exit status', 256)


$ /usr/bin/gdb /opt/local/bin/python2.7 /cores/core.92512 
GNU gdb 6.3.50-20050815 (Apple version gdb-1824) (Wed Feb  6 22:51:23 UTC 2013)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries ... done

Reading symbols for shared libraries . done
Reading symbols for shared libraries ....................................... done
#0  subtype_dealloc (self=0x103d1bb90) at Objects/typeobject.c:955
955     ++ tstate->trash_delete_nesting;
(gdb) bt
#0  subtype_dealloc (self=0x103d1bb90) at Objects/typeobject.c:955
#1  0x0000000103db4c9b in virtual thunk to IcePy::LoggerWrapper::~LoggerWrapper() (this=<value temporarily unavailable, due to optimizations>) at Logger.h:23
#2  0x00007fff8b3fc7c8 in __cxa_finalize ()
#3  0x00007fff8b3fc652 in exit ()
#4  0x000000010390853d in handle_system_exit () at Python/pythonrun.c:1774
#5  0x0000000103908169 in PyErr_PrintEx (set_sys_last_vars=1) at Python/pythonrun.c:1156
#6  0x0000000103907b42 in PyErr_Print [inlined] () at /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_python27/python27/work/Python-2.7.5/Python/pythonrun.c:1059
#7  0x0000000103907b42 in PyRun_SimpleFileExFlags (fp=<value temporarily unavailable, due to optimizations>, filename=<value temporarily unavailable, due to optimizations>, closeit=1, flags=0x7fff6343b3d0) at Python/pythonrun.c:947
#8  0x000000010391b8c0 in Py_Main (argc=<value temporarily unavailable, due to optimizations>, argv=0x7fff6343b428) at Modules/main.c:640
#9  0x000000010383df24 in _mh_execute_header ()


$ diff -U5 Python-2.7.{3,4}/Objects/typeobject.c
--- Python-2.7.3/Objects/typeobject.c   2012-04-09 16:07:34.000000000 -0700
+++ Python-2.7.4/Objects/typeobject.c   2013-04-06 07:02:39.000000000 -0700

@@ -887,10 +896,11 @@
 static void
 subtype_dealloc(PyObject *self)
 {
     PyTypeObject *type, *base;
     destructor basedealloc;
+    PyThreadState *tstate = PyThreadState_GET();
 
     /* Extract the type; we expect it to be a heap type */
     type = Py_TYPE(self);
     assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE);
 
@@ -936,12 +946,14 @@
 
     /* UnTrack and re-Track around the trashcan macro, alas */
     /* See explanation at end of function for full disclosure */
     PyObject_GC_UnTrack(self);
     ++_PyTrash_delete_nesting;
+    ++ tstate->trash_delete_nesting;
     Py_TRASHCAN_SAFE_BEGIN(self);
     --_PyTrash_delete_nesting;
+    -- tstate->trash_delete_nesting;
     /* DO NOT restore GC tracking at this point.  weakref callbacks
      * (if any, and whether directly here or indirectly in something we
      * call) may trigger GC, and if self is tracked at that point, it
      * will look like trash to GC and GC will try to delete self again.
      */

This core dump doesn't occur with Ice 3.5.0's Python bindings, so
doing a diff between 3.4.2 and 3.5.0, I found code to clean up the
logger using atexit().

Modified Paths:
--------------
    trunk/dports/python/py-zeroc-ice34/Portfile

Added Paths:
-----------
    trunk/dports/python/py-zeroc-ice34/files/patch-fix-python-2.7.4-core-dump.diff

Modified: trunk/dports/python/py-zeroc-ice34/Portfile
===================================================================
--- trunk/dports/python/py-zeroc-ice34/Portfile	2013-08-31 17:44:01 UTC (rev 110494)
+++ trunk/dports/python/py-zeroc-ice34/Portfile	2013-08-31 18:08:24 UTC (rev 110495)
@@ -5,7 +5,7 @@
 
 name            py-zeroc-ice34
 version         3.4.2
-revision        4
+revision        5
 set branch      [join [lrange [split ${version} .] 0 1] .]
 categories-append   devel
 maintainers     blair
@@ -40,7 +40,8 @@
                 rmd160 7ce680a4eb5fa9d0bb6f8b8910e267dfc2373d75
 patchfiles      patch-py.config.Make.rules.Darwin.diff \
                 patch-py.modules.IcePy.Communicator.cpp.diff \
-                patch-add-thrift-support.diff
+                patch-add-thrift-support.diff \
+                patch-fix-python-2.7.4-core-dump.diff
 platforms       darwin
 
 python.versions 25 26 27

Added: trunk/dports/python/py-zeroc-ice34/files/patch-fix-python-2.7.4-core-dump.diff
===================================================================
--- trunk/dports/python/py-zeroc-ice34/files/patch-fix-python-2.7.4-core-dump.diff	                        (rev 0)
+++ trunk/dports/python/py-zeroc-ice34/files/patch-fix-python-2.7.4-core-dump.diff	2013-08-31 18:08:24 UTC (rev 110495)
@@ -0,0 +1,81 @@
+diff -ru ../Ice-3.4.2.orig/py/modules/IcePy/Init.cpp ./py/modules/IcePy/Init.cpp
+--- ../Ice-3.4.2.orig/py/modules/IcePy/Init.cpp	2011-06-15 12:44:00.000000000 -0700
++++ ./py/modules/IcePy/Init.cpp	2013-08-31 10:43:39.000000000 -0700
+@@ -29,6 +29,7 @@
+ using namespace IcePy;
+ 
+ extern "C" PyObject* Ice_registerTypes(PyObject*, PyObject*);
++extern "C" PyObject* IcePy_cleanup(PyObject*);
+ 
+ static PyMethodDef methods[] =
+ {
+@@ -70,6 +71,8 @@
+         PyDoc_STR(STRCAST("internal function")) },
+     { STRCAST("loadSlice"), reinterpret_cast<PyCFunction>(IcePy_loadSlice), METH_VARARGS,
+         PyDoc_STR(STRCAST("loadSlice(cmd) -> None")) },
++    { STRCAST("cleanup"), reinterpret_cast<PyCFunction>(IcePy_cleanup), METH_NOARGS,
++        PyDoc_STR(STRCAST("internal function")) },
+     { 0, 0 } /* sentinel */
+ };
+ 
+@@ -150,3 +153,13 @@
+         return;
+     }
+ }
++
++extern "C"
++PyObject*
++IcePy_cleanup(PyObject* /*self*/)
++{
++    cleanupLogger();
++
++    Py_INCREF(Py_None);
++    return Py_None;
++}
+diff -ru ../Ice-3.4.2.orig/py/modules/IcePy/Logger.cpp ./py/modules/IcePy/Logger.cpp
+--- ../Ice-3.4.2.orig/py/modules/IcePy/Logger.cpp	2011-06-15 12:44:00.000000000 -0700
++++ ./py/modules/IcePy/Logger.cpp	2013-08-31 10:33:03.000000000 -0700
+@@ -400,6 +400,15 @@
+     return true;
+ }
+ 
++void
++IcePy::cleanupLogger()
++{
++    //
++    // Python is about to exit; we need to remove the wrapper around the process logger.
++    //
++    Ice::setProcessLogger(0);
++}
++
+ PyObject*
+ IcePy::createLogger(const Ice::LoggerPtr& logger)
+ {
+diff -ru ../Ice-3.4.2.orig/py/modules/IcePy/Logger.h ./py/modules/IcePy/Logger.h
+--- ../Ice-3.4.2.orig/py/modules/IcePy/Logger.h	2011-06-15 12:44:00.000000000 -0700
++++ ./py/modules/IcePy/Logger.h	2013-08-31 10:32:30.000000000 -0700
+@@ -41,6 +41,8 @@
+ 
+ bool initLogger(PyObject*);
+ 
++void cleanupLogger();
++
+ //
+ // Create a Python object that delegates to a C++ implementation.
+ //
+diff -ru ../Ice-3.4.2.orig/py/python/Ice.py ./py/python/Ice.py
+--- ../Ice-3.4.2.orig/py/python/Ice.py	2011-06-15 12:44:00.000000000 -0700
++++ ./py/python/Ice.py	2013-08-31 10:44:36.000000000 -0700
+@@ -53,6 +53,12 @@
+     sys.setdlopenflags(_dlopenflags)
+ 
+ #
++# Give the extension an opportunity to clean up before a graceful exit.
++#
++import atexit
++atexit.register(IcePy.cleanup)
++
++#
+ # Add some symbols to the Ice module.
+ #
+ ObjectPrx = IcePy.ObjectPrx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20130831/96147eda/attachment.html>


More information about the macports-changes mailing list