Re: Possible bug with mmap on XP?
On Feb 2 18:16, Dave Bodenstab wrote: I searched the mailing list archives and googled, but failed to find anything specific to XP regarding this... I am using the latest version (1.5.19-4) of Cygwin. I had previously ported a unix prog that used mmap to Cygwin. On win2k it works fine. When I copied the prog to a newly-installed win XP professional system, I get: mmap failed (Permission denied) when attempting to do a 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? This is a constraint of the underlying OS, yes. The old implementation of mmap used up to 1.5.18 didn't support PROT_EXEC at all, it was just fake. Since 1.5.19, PROT_EXEC mapping is now supported correctly, which means, the underlying NT functions are called requesting PAGE_EXECUTE protection. But here's the problem. To create file mappings with PAGE_EXECUTE protection, the file must be opened with GENERIC_EXECUTE access. This is done internally in mmap, but it fails if the file doesn't have the execute permission set. Whether or not this behaviour is backed by SUSv3, I'm not sure. SUSv3 states if an implementation cannot support the combination of access types specified by prot, the call to mmap() shall fail., so here's one situation in which the implementation can't support the combination of access types specified by prot. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat -- 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/
Re: Possible bug with mmap on XP?
On Fri, 3 Feb 2006, Christopher Faylor wrote: ... One person even reported that a Cygwin bug caused OS wrapping and he found himself running FreeBSD... Is that the Blue Screen Of Life? Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_[EMAIL PROTECTED] | [EMAIL PROTECTED] ZZZzz /,`.-'`'-. ;-;;,_Igor Peshansky, Ph.D. (name changed!) |,4- ) )-,_. ,\ ( `'-' old name: Igor Pechtchanski '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte. But no -- you are no fool; you call yourself a fool, there's proof enough in that! -- Rostand, Cyrano de Bergerac -- 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/
Re: Possible bug with mmap on XP?
On Thu Feb 2 22:55:08 2006 Corinna Vinschen [EMAIL PROTECTED] wrote: Is this the way things are supposed to work on XP? This is a constraint of the underlying OS, yes. The old implementation of mmap used up to 1.5.18 didn't support PROT_EXEC at all, it was just fake. Since 1.5.19, PROT_EXEC mapping is now supported correctly, which means, the underlying NT functions are called requesting PAGE_EXECUTE protection. But here's the problem. To create file mappings with PAGE_EXECUTE protection, the file must be opened with GENERIC_EXECUTE access. This is done internally in mmap, but it fails if the file doesn't have the execute permission set. Whether or not this behaviour is backed by SUSv3, I'm not sure. SUSv3 states if an implementation cannot support the combination of access types specified by prot, the call to mmap() shall fail., so here's one situation in which the implementation can't support the combination of access types specified by prot. OK. I would like to modify my program to set the required permissions. Is the mapping between Cygwin's uname()'s sysname and XP, NT, 98SE, 98, etc. available somewhere? Actually, if I could just tell if the underlying windows is XP, that would be sufficient I think. Thanks. -- 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/
Re: Possible bug with mmap on XP?
Dave Bodenstab wrote: On Thu Feb 2 22:55:08 2006 Corinna Vinschen [EMAIL PROTECTED] wrote: Is this the way things are supposed to work on XP? This is a constraint of the underlying OS, yes. The old implementation of mmap used up to 1.5.18 didn't support PROT_EXEC at all, it was just fake. Since 1.5.19, PROT_EXEC mapping is now supported correctly, which means, the underlying NT functions are called requesting PAGE_EXECUTE protection. But here's the problem. To create file mappings with PAGE_EXECUTE protection, the file must be opened with GENERIC_EXECUTE access. This is done internally in mmap, but it fails if the file doesn't have the execute permission set. Whether or not this behaviour is backed by SUSv3, I'm not sure. SUSv3 states if an implementation cannot support the combination of access types specified by prot, the call to mmap() shall fail., so here's one situation in which the implementation can't support the combination of access types specified by prot. OK. I would like to modify my program to set the required permissions. Is the mapping between Cygwin's uname()'s sysname and XP, NT, 98SE, 98, etc. available somewhere? Actually, if I could just tell if the underlying windows is XP, that would be sufficient I think. Thanks. XP == NT_5.1 2k == NT_5.0 98 == 4.10 95 == 4.0 (I believe) I don't know what WinME is, and I don't particularly wish to either. I /suspect/ that NT4 is likely to be NT_4.0, but this may have changed with the later service packs (doubtful though, in my opinion). I don't have an nt4 box to verify this with however. Chris -- Spinning complacently in the darkness, covered and blinded by a blanket of little lives, false security has lulled the madness of this world into a slumber. Wake up! An eye is upon you, staring straight down and keenly through, seeing all that you are and everything that you will never be. Yes, an eye is upon you, an eye ready to blink. So face forward, with arms wide open and mind reeling. Your future has arrived... Are you ready to go? -- 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/
Re: Possible bug with mmap on XP?
I would like to modify my program to set the required permissions. Is the mapping between Cygwin's uname()'s sysname and XP, NT, 98SE, 98, etc. available somewhere? Actually, if I could just tell if the underlying windows is XP, that would be sufficient I think. The end of wincap.cc shows the mapping between the Windows version string (which gets put in the sysname portion of uname(2)) vs. the os capabilities in use (with some pretty informative variable names). http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/cygwin/wincap.cc?rev=1.50content-type=text/x-cvsweb-markupcvsroot=src Wouldn't you know it - a version of NT-5.1 selects wincap_xp? -- Eric Blake -- 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/
Possible bug with mmap on XP?
I searched the mailing list archives and googled, but failed to find anything specific to XP regarding this... I am using the latest version (1.5.19-4) of Cygwin. I had previously ported a unix prog that used mmap to Cygwin. On win2k it works fine. When I copied the prog to a newly-installed win XP professional system, I get: mmap failed (Permission denied) when attempting to do a 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? 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. PPS. If this is a limitation for XP, is there a way for a Cygwin program to tell if it's running on XP? Thank you. [ 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. ] -- 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/
Re: Possible bug with mmap on XP?
-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,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 isolation. - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -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/
Re: Possible bug with mmap on XP?
Thanks for the reply. On Thu, 02 Feb 2006 21:47:55 -0700 Eric Blake [EMAIL PROTECTED] wrote: 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. It can be found at http://www.bodenstab.org/files/mmaptest.c 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. Is there a reference for what is returned for each windows release? On my only windows (I only have these for a couple of games and the digital cameras) systems I get: Win98SE sysname=CYGWIN_98-4.10 WinXP sysname=CYGWIN_NT-5.1 I would have expected XP rather than NT... I thought I read somewhere that NT is obsolete or at least unsupported now? Does the 4.10 or 5.1 mean anything important? -- 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/
Re: Possible bug with mmap on XP?
On Fri, Feb 03, 2006 at 12:36:42AM -0600, Dave Bodenstab wrote: Is there a reference for what is returned for each windows release? On my only windows (I only have these for a couple of games and the digital cameras) systems I get: Win98SE sysname=CYGWIN_98-4.10 WinXP sysname=CYGWIN_NT-5.1 I would have expected XP rather than NT... I thought I read somewhere that NT is obsolete or at least unsupported now? Does the 4.10 or 5.1 mean anything important? Don't worry. Cygwin automatically downgrades your Windows software to the level that it requires for correct operation -- NT-5.1 in this case. You're actually pretty lucky since, in many cases, Cygwin may end up downgrading the OS all the way back to MS-DOS 6.0, and in certain rare cases straight to CPM. One person even reported that a Cygwin bug caused OS wrapping and he found himself running FreeBSD, but I think that might have just been a cockpit error. cgf -- 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/