... /usr/bin/clang -Wl,-stack_size,1000000 -framework CoreFoundation -o python Modules/python.o libpython3.4dm.a -ldl -framework CoreFoundation ./python -E -S -m sysconfig --generate-posix-vars Debug memory block at address p=0x7f9fba414160: API 'm' 948 bytes originally requested The 7 pad bytes at p-7 are FORBIDDENBYTE, as expected. The 8 pad bytes at tail=0x7f9fba414514 are FORBIDDENBYTE, as expected. The block was made by call #5440 to debug malloc/realloc. Data at p: 2f 00 00 00 55 00 00 00 ... 73 00 00 00 00 00 00 00 Fatal Python error: bad ID: Allocated using API 'm', verified using API 'r' Current thread 0x00007fff74872180: make: *** [pybuilddir.txt] Abort trap: 6
Further testing shows that the problem is not limited to OS X 10.8 or clang: a similar debug build attempt fails on OS X 10.6 with Apple gcc-4.2. ./configure --with-pydebug CC=gcc-4.2 MACOSX_DEPLOYMENT_TARGET=10.6 make gcc-4.2 -Wl,-stack_size,1000000 -framework CoreFoundation -o python.exe Modules/python.o libpython3.4dm.a -ldl -framework CoreFoundation ./python.exe -E -S -m sysconfig --generate-posix-vars Debug memory block at address p=0x100515a40: API 'm' 232 bytes originally requested The 7 pad bytes at p-7 are FORBIDDENBYTE, as expected. The 8 pad bytes at tail=0x100515b28 are FORBIDDENBYTE, as expected. The block was made by call #5440 to debug malloc/realloc. Data at p: 2f 00 00 00 75 00 00 00 ... 6e 00 00 00 00 00 00 00 Fatal Python error: bad ID: Allocated using API 'm', verified using API 'r' Current thread 0x00007fff70f4bcc0: make: *** [pybuilddir.txt] Abort trap
Here's the traceback in gdb from the 10.6 case above: (gdb) where #0 0x00007fff891ba0b6 in __kill () #1 0x00007fff8925a9f6 in abort () #2 0x00000001001cd4fd in Py_FatalError (msg=Could not find the frame base for "Py_FatalError". ) at Python/pythonrun.c:2380 #3 0x000000010008ee41 in _PyMem_DebugCheckAddress (api=114 'r', p=0x100514bb0) at Objects/obmalloc.c:1857 #4 0x000000010008e9e5 in _PyMem_DebugFree (ctx=0x1002f6640, p=0x100514bb0) at Objects/obmalloc.c:1743 #5 0x000000010008cf72 in PyMem_RawFree (ptr=0x100514bb0) at Objects/obmalloc.c:270 #6 0x00000001001f3324 in calculate_path () at ./Modules/getpath.c:557 #7 0x00000001001f3cce in Py_GetProgramFullPath () at ./Modules/getpath.c:867 #8 0x00000001001dabc0 in _PySys_Init () at ./Python/sysmodule.c:1619 #9 0x00000001001c727e in _Py_InitializeEx_Private (install_sigs=1, install_importlib=1) at Python/pythonrun.c:352 #10 0x00000001001c7555 in Py_InitializeEx (install_sigs=1) at Python/pythonrun.c:419 #11 0x00000001001c7565 in Py_Initialize () at Python/pythonrun.c:425 #12 0x00000001001f5698 in Py_Main (argc=1, argv=0x1005060e0) at Modules/main.c:673 #13 0x0000000100001090 in main (argc=1, argv=0x7fff5bfffbe0) at ./Modules/python.c:63
I patched PyMem_RawMalloc(), but I forgot _Py_DecodeUTF8_surrogateescape() which is specific to OSX. The following changeset fixed this issue: Ok, I missed this function specific to OSX: changeset: 84501:31a635303e55 tag: tip user: Victor Stinner <victor.stinner@gmail.com> date: Sun Jul 07 22:57:45 2013 +0200 files: Objects/unicodeobject.c description: Issue #18203: Fix _Py_DecodeUTF8_surrogateescape(), use PyMem_RawMalloc() as _Py_char2wchar()
History
Date
User
Action
Args
2022-04-11 14:57:47
admin
set
github: 62598
2013-07-07 21:02:03
vstinner
set
status: open -> closedresolution: fixedmessages: +
2013-07-07 20:54:33
ned.deily
set
messages: +
2013-07-07 20:49:22
ned.deily
set
messages: + title: Debug Python build fails on OS X with current clang: Fatal Python error: bad ID: Allocated using API 'm', verified using API 'r' -> Debug Python build fails on OS X: Fatal Python error: bad ID: Allocated using API 'm', verified using API 'r'