This is the mail archive of the
mailing list for the Cygwin project.
Re: Possible bug with mmap on XP?
- From: Eric Blake <ebb9 at byu dot net>
- To: Dave Bodenstab <dave at bodenstab dot org>
- Cc: cygwin at cygwin dot com
- Date: Thu, 02 Feb 2006 21:47:55 -0700
- Subject: Re: Possible bug with mmap on XP?
- References: <200602030016.k130GYOk002533@base686.home.org>
-----BEGIN PGP SIGNED MESSAGE-----
According to Dave Bodenstab on 2/2/2006 5:16 PM:
> mmap(0,1500,PROT_EXEC|PROT_READ|PROT_WRITE,MAP_PRIVATE,<the fd>,0)
> I've found that changing the permissions (chmod +x) on the file being
> mmap'ed makes the problem go away.
> Is this the way things are supposed to work on XP?
Cygwin's behavior sounds reasonable to me - POSIX permits an
implementation to fail with EACCESS if the prot parameter requests writes
but filedes was not opened for writing, and permits failure with ENOTSUP
if a combination of prot flags is not supported. But I see nothing in
POSIX that requires PROT_EXEC to either fail or succeed based on whether
filedes is tied to a file that has execute privileges, so you are treading
in unspecified waters.
> PS. I have a test program that demonstrates this problem, but I wanted
> to ask if this is a known problem before I start posting test programs.
A test program would be very helpful.
> PPS. If this is a limitation for XP, is there a way for a Cygwin program
> to tell if it's running on XP?
Yes, uname(2) can be used to give you an idea of what version of Windows
you are running on.
> My program generates x86 machine code and writes it to a file.
> The program then mmap's the file and executes the code.
> The problem is that I want the file prepended with '#!/bin/myprog\n"
> to be "executable", but I don't want a file with just the raw
> x86 code to be "executable" -- because it isn't without being
> run under control of my program that generated it. This works
> entirely correctly on Linux, FreeBSD and Solaris.
"works entirely correctly" is subjective, since there is no standards
document that requires it to either succeed or to fail. However, since
cygwin strives to emulate Linux, I imagine Corinna will probably
investigate this further to see if it really is an inherent limitation of
XP. And in the meantime, you have a workaround of marking files
executable that have executable bytes, even if they are not executable in
Life is short - so eat dessert first!
Eric Blake firstname.lastname@example.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html