]> granicus.if.org Git - python/commitdiff
bpo-36648: fix mmap issue for VxWorks (GH-12394)
authorLihua Zhao <44661095+LihuaZhao@users.noreply.github.com>
Tue, 21 May 2019 10:50:14 +0000 (18:50 +0800)
committerVictor Stinner <vstinner@redhat.com>
Tue, 21 May 2019 10:50:14 +0000 (12:50 +0200)
The mmap module set MAP_SHARED flag when map anonymous memory, however VxWorks
only support MAP_PRIVATE when map anonymous memory, this commit clear MAP_SHARED
and set MAP_PRIVATE.

Misc/NEWS.d/next/Library/2019-03-18-14-25-36.bpo-31904.ds3d67.rst [new file with mode: 0644]
Modules/mmapmodule.c

diff --git a/Misc/NEWS.d/next/Library/2019-03-18-14-25-36.bpo-31904.ds3d67.rst b/Misc/NEWS.d/next/Library/2019-03-18-14-25-36.bpo-31904.ds3d67.rst
new file mode 100644 (file)
index 0000000..fd82fe0
--- /dev/null
@@ -0,0 +1 @@
+Fix mmap fail for VxWorks
index 33366b2d933194a13930410e4d41f50077c08120..917c6362c11d9af0861949eb522186c9cffa4927 100644 (file)
@@ -1164,6 +1164,13 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
 #ifdef MAP_ANONYMOUS
         /* BSD way to map anonymous memory */
         flags |= MAP_ANONYMOUS;
+
+        /* VxWorks only supports MAP_ANONYMOUS with MAP_PRIVATE flag */
+#ifdef __VXWORKS__
+        flags &= ~MAP_SHARED;
+        flags |= MAP_PRIVATE;
+#endif
+
 #else
         /* SVR4 method to map anonymous memory is to open /dev/zero */
         fd = devzero = _Py_open("/dev/zero", O_RDWR);