summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2018-05-18 18:31:13 +0200
committerStefan Behnel <stefan_ml@behnel.de>2018-05-18 18:33:54 +0200
commit8e618b58edbfc145c81b23f8bb7208cce0d3221c (patch)
tree9f205d087a0bd859c951a6ec6753ea9d4c0c76d7
parent27ad490bddddedfcc332c8f98656cccdc5e60dc2 (diff)
downloadcython-8e618b58edbfc145c81b23f8bb7208cce0d3221c.tar.gz
Avoid segfault due to a bug in g++ 4.4.7 when the -Os setting for the module init function is enabled.
Closes #2235.
-rw-r--r--CHANGES.rst3
-rw-r--r--Cython/Utility/ModuleSetupCode.c3
2 files changed, 5 insertions, 1 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 26b48b0dc..3f60a8777 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -16,6 +16,9 @@ Bugs fixed
* ``UnicodeEncodeError`` in Py2 when ``%s`` formatting is optimised for
unicode strings. (Github issue #2276)
+* Work around a crash bug in g++ 4.4.x by disabling the size reduction setting
+ of the module init function in this version. (Github issue #2235)
+
0.28.2 (2018-04-13)
===================
diff --git a/Cython/Utility/ModuleSetupCode.c b/Cython/Utility/ModuleSetupCode.c
index a96f6f5e9..c1ba400fb 100644
--- a/Cython/Utility/ModuleSetupCode.c
+++ b/Cython/Utility/ModuleSetupCode.c
@@ -669,7 +669,8 @@ static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
#define CYTHON_SMALL_CODE
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
+ // At least g++ 4.4.7 can generate crashing code with this option. (GH #2235)
#define CYTHON_SMALL_CODE __attribute__((optimize("Os")))
#else
#define CYTHON_SMALL_CODE