X-Spam-Check-By: sourceware.org Message-ID: <43E2E07B.5000702@byu.net> Date: Thu, 02 Feb 2006 21:47:55 -0700 From: Eric Blake User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) MIME-Version: 1.0 To: Dave Bodenstab CC: cygwin AT cygwin DOT com Subject: Re: Possible bug with mmap on XP? References: <200602030016 DOT k130GYOk002533 AT base686 DOT home DOT org> In-Reply-To: <200602030016.k130GYOk002533@base686.home.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Dave Bodenstab on 2/2/2006 5:16 PM: > mmap(0,1500,PROT_EXEC|PROT_READ|PROT_WRITE,MAP_PRIVATE,,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 isolation. - -- Life is short - so eat dessert first! Eric Blake ebb9 AT byu DOT net -----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 iD8DBQFD4uB784KuGfSFAYARAnb1AJ4zzF35RJOCxrd1phaKMc3WPyl3ewCfePkw Ga9x7IY1cFr8BL/KI3HPhQ0= =qcdC -----END PGP SIGNATURE----- -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/