Fw: Re: Fw: Re: Why do these mprotect always fail?

w6b7rk5yu4mt25v3 w6b7rk5yu4mt25v3@protonmail.com
Wed Feb 15 15:31:38 GMT 2023

I asked the developer of the interpreter. He said it's OK to use the PAGE_SIZE value different than 4096. So I used this dirty hack:

#ifndef __CYGWIN__
#define PAGE_SIZE 4096

This means on Cygwin it will use the default PAGE_SIZE defined on limits.h (I'm taking advantage of the naming conflict here so I don't have to rename PAGE_SIZE to JIT_PAGE_SIZE as suggested by the developer of the interpreter).

The result is it's no longer error with "Unable to mprotect" but will silently crashed without any error messages printed on the screen. So after all, it's Cygwin's quirks here.

Sent with Proton Mail secure email.

------- Forwarded Message -------
From: Oskar Skog via Cygwin <cygwin@cygwin.com>
Date: On Wednesday, February 15th, 2023 at 20:02
Subject: Re: Fw: Re: Why do these mprotect always fail?
To: cygwin@cygwin.com <cygwin@cygwin.com>

> On 2023-02-15 14:40, w6b7rk5yu4mt25v3 via Cygwin wrote:
> > You misunderstood what I said.
> > 
> > It's really just a naming conflict and a coincident. On the context of the source code (it's an interpreter), PAGE_SIZE is indeed JIT_PAGE_SIZE (not the system page size, but the page size defined internally by the interpreter). On Linux, the name doesn't conflict. On Cygwin, I found on limits.h and cygwin/limits.h already defined PAGE_SIZE so it caused a naming conflict:
> > 
> > #define __PAGESIZE 65536
> > 
> > But the problem not related to the naming conflict. If I renamed PAGE_SIZE to JIT_PAGE_SIZE, the problem is still there. The problem is Cygwin will not work with JIT_PAGE_SIZE = 4096. Please have a look at the code I posted. It will always error with "Unable to mprotect".
> The Linux man page for mprotect says that the address MUST be aligned
> (with the systems PAGE_SIZE). Your call to posix_memalign is NOT
> aligning the allocation with the systems PAGE_SIZE (65536), but with
> your PAGE_SIZE (4096).
> You need to allocate memory that is aligned with the systems PAGE_SIZE.
> Eg.
> if(posix_memalign((void**)&buffer, (PAGE_SIZE>JIT_PAGE_SIZE) ? PAGE_SIZE
> : JIT_PAGE_SIZE, available)) { ... }
> --
> Problem reports: https://cygwin.com/problems.html
> FAQ: https://cygwin.com/faq/
> Documentation: https://cygwin.com/docs.html
> Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0x473CD05C78734E49.asc
Type: application/pgp-keys
Size: 2444 bytes
Desc: not available
URL: <https://cygwin.com/pipermail/cygwin/attachments/20230215/4cfc67a2/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.sig
Type: application/octet-stream
Size: 444 bytes
Desc: not available
URL: <https://cygwin.com/pipermail/cygwin/attachments/20230215/4cfc67a2/attachment-0001.obj>

More information about the Cygwin mailing list