This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: dlmalloc.c needs _GNU_SOURCE for mremap()
Type: behavior Stage:
Components: Extension Modules Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: barry Nosy List: barry, hfuru, python-dev, vstinner
Priority: normal Keywords:

Created on 2010-11-04 11:43 by hfuru, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (5)
msg120391 - (view) Author: Hallvard B Furuseth (hfuru) Date: 2010-11-04 11:43
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.
msg140688 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2011-07-19 18:54
I'm running into this while trying to backport Python 2.7.2 to Ubuntu 10.04.  Our build machines are throwing an error because they catch the implicit cast so as to prevent problems on ia64 and amd64.

http://wiki.debian.org/IMplicitPointerConversions

I haven't quite gotten the patch to work yet, but when I do, I'll look at applying this patch upstream as well.
msg140695 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2011-07-19 21:26
Python 3.1 is in security only mode, so this patch cannot be applied to that version.
msg140711 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-07-19 23:28
New changeset 8f3cc8ffc3ff by Barry Warsaw in branch '2.7':
- Issue #10309: Define _GNU_SOURCE so that mremap() gets the proper
http://hg.python.org/cpython/rev/8f3cc8ffc3ff

New changeset cc00e09404e6 by Barry Warsaw in branch '3.2':
- Issue #10309: Define _GNU_SOURCE so that mremap() gets the proper
http://hg.python.org/cpython/rev/cc00e09404e6

New changeset 9986fff720a2 by Barry Warsaw in branch 'default':
- Issue #10309: Define _GNU_SOURCE so that mremap() gets the proper
http://hg.python.org/cpython/rev/9986fff720a2
msg188140 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-04-30 08:05
New changeset 663800e18fef by Gregory P. Smith in branch '3.2':
This local change was lost during the fixing of issue17192 to update
http://hg.python.org/cpython/rev/663800e18fef

New changeset 7438d202e380 by Gregory P. Smith in branch '2.7':
This local change was lost during the fixing of issue17192 to update
http://hg.python.org/cpython/rev/7438d202e380
History
Date User Action Args
2022-04-11 14:57:08adminsetgithub: 54518
2013-04-30 08:05:38python-devsetmessages: + msg188140
2011-07-19 23:30:37barrysetstatus: open -> closed
resolution: fixed
2011-07-19 23:28:37python-devsetnosy: + python-dev
messages: + msg140711
2011-07-19 21:26:18barrysetmessages: + msg140695
versions: + Python 3.3, - Python 3.1
2011-07-19 19:07:07barrysetassignee: barry
2011-07-19 19:02:50brian.curtinsetassignee: theller -> (no value)

nosy: - theller
2011-07-19 18:54:12barrysetnosy: + barry

messages: + msg140688
versions: + Python 2.7
2010-11-04 13:15:41hfurusetversions: + Python 3.1
2010-11-04 12:53:09pitrousetassignee: theller

nosy: + theller
2010-11-04 11:55:21vstinnersetnosy: + vstinner
2010-11-04 11:43:44hfurucreate