[New-bugs-announce] [issue10309] dlmalloc.c needs _GNU_SOURCE for mremap()

Hallvard B Furuseth report at bugs.python.org
Thu Nov 4 12:43:47 CET 2010

New submission from Hallvard B Furuseth <h.b.furuseth at usit.uio.no>:

dlmalloc uses mremap() which is undeclared on Linux, needs _GNU_SOURCE.
This can break at least on hosts where void* = 64 bits and int (default
return type) 32 bits, since some bits in the return type are lost.

A minimal patch is:

--- Modules/_ctypes/libffi/src/dlmalloc.c
+++ Modules/_ctypes/libffi/src/dlmalloc.c
@@ -459,2 +459,4 @@
 #define MMAP_CLEARS 0 /* WINCE and some others apparently don't clear */
+#elif !defined _GNU_SOURCE
+#define _GNU_SOURCE 1           /* mremap() in Linux sys/mman.h */
 #endif  /* WIN32 */

However the (char*)CALL_MREMAP() cast looks like a broken fix for this,
it suppresses a warning instead of fixing it.  Maybe you should remove
the cast and instead assign CALL_MREMAP() to a void*, to catch any
similar trouble in the future.

components: Extension Modules
messages: 120391
nosy: hfuru
priority: normal
severity: normal
status: open
title: dlmalloc.c needs _GNU_SOURCE for mremap()
type: behavior
versions: Python 3.2

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list