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.

Author lzhao
Recipients lzhao, vstinner
Date 2019-04-18.10:10:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1555582219.36.0.0318942357966.issue36648@roundup.psfhosted.org>
In-reply-to
Content
>>What is the current behavior of m = mmap.mmap(-1, 100)? Does it raise an exception?

No, the following statement will return -1 without PR 12394

    m_obj->data = mmap(NULL, map_size,
                       prot, flags,
                       fd, offset);

>>I don't understand why PR 12394 modifies flags afterwards, whereas "m = mmap.mmap(-1, 100)" doesn't specify explicitly flags. So the bug looks to be default flags set by Python, no?

Yes, this statement doesn't specify the flag, but as you said, the new_mmap_object() firstly set MAP_SHARED for flag, and in later code:

    if (fd == -1) {
        m_obj->fd = -1;
    .....
#ifdef MAP_ANONYMOUS
        /* BSD way to map anonymous memory */
        flags |= MAP_ANONYMOUS;

#else
#endif

This routine will pass (MAP_ANONYMOUS | MAP_SHARED) to mmap and fd is -1, this is true for Linux, but for VxWorks, if fd is -1, the flag type should be (MAP_ANONYMOUS | MAP_PRIVATE), and this behavior is not part of the POSIX standard, we can't say VxWorks isn't right.

So my changes clear MAP_SHARED and set MAP_PRIVATE when the system type is VxWorks.

>>Is MAP_SHARED constant available in C on VxWorks?

Yes, but for MAP_ANONYMOUS, it require set MAP_PRIVATE.

This PR still is try to enhance VxWorks support, doesn't affect Python user, and only change the behavior of VxWorks, other system don't have this issue, and also won't be influenced
History
Date User Action Args
2019-04-18 10:10:19lzhaosetrecipients: + lzhao, vstinner
2019-04-18 10:10:19lzhaosetmessageid: <1555582219.36.0.0318942357966.issue36648@roundup.psfhosted.org>
2019-04-18 10:10:19lzhaolinkissue36648 messages
2019-04-18 10:10:19lzhaocreate