From: Jacek Konieczny Date: Fri, 21 Feb 2014 19:47:49 +0000 (+0100) Subject: Fix crash in benchmarks/chain.py due to GC assert X-Git-Tag: auto/th/python-greenlet-0.4.2-1~1 X-Git-Url: http://git.pld-linux.org/gitweb.cgi?a=commitdiff_plain;h=c12edfc0ab245aabff5c06beee2b2c708d2edc94;p=packages%2Fpython-greenlet.git Fix crash in benchmarks/chain.py due to GC assert http://www.mail-archive.com/pld-devel-en@lists.pld-linux.org/msg07983.html https://github.com/python-greenlet/greenlet/issues/44 Release: 1 --- diff --git a/python-greenlet-gc_assertion_error.patch b/python-greenlet-gc_assertion_error.patch new file mode 100644 index 0000000..4290fdc --- /dev/null +++ b/python-greenlet-gc_assertion_error.patch @@ -0,0 +1,89 @@ +commit b24bde4302b0f85aa1bc0382299d41923eab614e +Author: Alexey Borzenkov +Date: Fri Feb 21 22:32:13 2014 +0400 + + green_dealloc: don't use trashcan on non-GC'ible greenlets + + There's an assert in Python's object.c that checks trashcan + is only used for garbage collectible objects. Since not all + greenlets are garbage collectible trashcan use must be + conditional. + +diff --git a/greenlet.c b/greenlet.c +index c99f13f..580bf7d 100644 +--- a/greenlet.c ++++ b/greenlet.c +@@ -941,14 +941,10 @@ static int green_clear(PyGreenlet* self) + } + #endif + +-static void green_dealloc(PyGreenlet* self) ++static void green_dealloc_safe(PyGreenlet* self) + { + PyObject *error_type, *error_value, *error_traceback; + +-#if GREENLET_USE_GC +- PyObject_GC_UnTrack((PyObject *)self); +- Py_TRASHCAN_SAFE_BEGIN(self); +-#endif /* GREENLET_USE_GC */ + if (PyGreenlet_ACTIVE(self) && self->run_info != NULL && !PyGreenlet_MAIN(self)) { + /* Hacks hacks hacks copied from instance_dealloc() */ + /* Temporarily resurrect the greenlet. */ +@@ -995,7 +991,7 @@ static void green_dealloc(PyGreenlet* self) + --Py_TYPE(self)->tp_frees; + --Py_TYPE(self)->tp_allocs; + #endif /* COUNT_ALLOCS */ +- goto green_dealloc_end; ++ return; + } + } + if (self->weakreflist != NULL) +@@ -1007,12 +1003,24 @@ static void green_dealloc(PyGreenlet* self) + Py_CLEAR(self->exc_traceback); + Py_CLEAR(self->dict); + Py_TYPE(self)->tp_free((PyObject*) self); +-green_dealloc_end: ++} ++ + #if GREENLET_USE_GC +- Py_TRASHCAN_SAFE_END(self); +-#endif /* GREENLET_USE_GC */ +- return; ++static void green_dealloc(PyGreenlet* self) ++{ ++ PyObject_GC_UnTrack((PyObject *)self); ++ if (PyObject_IS_GC(self)) { ++ Py_TRASHCAN_SAFE_BEGIN(self); ++ green_dealloc_safe(self); ++ Py_TRASHCAN_SAFE_END(self); ++ } else { ++ /* This object cannot be garbage collected, so trashcan is not allowed */ ++ green_dealloc_safe(self); ++ } + } ++#else ++#define green_dealloc green_dealloc_safe ++#endif + + static PyObject* single_result(PyObject* results) + { + +commit 07b799de4e8f12a5cada4124184c772340a8c675 (HEAD, origin/master, origin/HEAD, master) +Author: Alexey Borzenkov +Date: Fri Feb 21 22:43:10 2014 +0400 + + green_dealloc: cast to PyObject * in PyObject_IS_GC + +diff --git a/greenlet.c b/greenlet.c +index 580bf7d..a1a27c0 100644 +--- a/greenlet.c ++++ b/greenlet.c +@@ -1009,7 +1009,7 @@ static void green_dealloc_safe(PyGreenlet* self) + static void green_dealloc(PyGreenlet* self) + { + PyObject_GC_UnTrack((PyObject *)self); +- if (PyObject_IS_GC(self)) { ++ if (PyObject_IS_GC((PyObject *)self)) { + Py_TRASHCAN_SAFE_BEGIN(self); + green_dealloc_safe(self); + Py_TRASHCAN_SAFE_END(self); diff --git a/python-greenlet.spec b/python-greenlet.spec index ae71875..e49520f 100644 --- a/python-greenlet.spec +++ b/python-greenlet.spec @@ -21,12 +21,13 @@ Summary: Lightweight in-process concurrent programming Name: python-%{module} Version: 0.4.2 -Release: 0.1 +Release: 1 License: MIT & PSF Group: Libraries/Python URL: http://pypi.python.org/pypi/greenlet Source0: http://pypi.python.org/packages/source/g/greenlet/%{module}-%{version}.zip # Source0-md5: 580a8a5e833351f7abdaedb1a877f7ac +Patch0: %{name}-gc_assertion_error.patch %if %{with python2} BuildRequires: python-devel BuildRequires: python-setuptools @@ -75,6 +76,7 @@ This package contains header files required for C modules development. %prep %setup -q -n greenlet-%{version} +%patch0 -p1 %build %if %{with python2}