Permalink
Browse files

Fix segfault under gcc 8.

CPython had undefined behavior for a long time, and gcc 8 turned this
into a segfault.

This commit description explains it well:

python/cpython@e348c8d

There was a 'long double' to ensure a larger alignment (which apparently
mattered for some platforms, at some time in the past).  But Python's
memory allocator only guarantees 8-byte alignment, which caused the
undefined behavior.

Other background:

https://www.mail-archive.com/gcc-bugs@gcc.gnu.org/msg570352.htmlo

https://mail.python.org/pipermail/python-dev/2018-January/152000.html

Fixes issue #107.
  • Loading branch information...
Andy Chu
Andy Chu committed Jun 11, 2018
1 parent 5f4ef18 commit 3c2a7c2d896c8e9e133f26633166e5857434b8bf
Showing with 7 additions and 1 deletion.
  1. +7 −1 Python-2.7.13/Include/objimpl.h
@@ -255,7 +255,13 @@ typedef union _gc_head {
union _gc_head *gc_prev;
Py_ssize_t gc_refs;
} gc;
long double dummy; /* force worst-case alignment */
/* OVM CHANGE
Ported this commit from Python 3. Python 2.7 uses a more complicated change
for ABI compatibility.
https://github.com/python/cpython/commit/e348c8d154cf6342c79d627ebfe89dfe9de23817
*/
double dummy; /* force worst-case alignment */
} PyGC_Head;
extern PyGC_Head *_PyGC_generation0;

0 comments on commit 3c2a7c2

Please sign in to comment.