From: Oskar Skog <oskar@oskog97.com>
To: cygwin@cygwin.com
Subject: Re: Fw: Re: Why do these mprotect always fail?
Date: Wed, 15 Feb 2023 15:02:09 +0200 [thread overview]
Message-ID: <d594b5d0-8810-c752-97ff-a28b2524552f@oskog97.com> (raw)
In-Reply-To: <0Qjpbo0t_1WTd9--kVw5gLR1PdJzG7myKYzhxdzDIqnWYwLnywFCtSbekykskWViaSJM_bcLQBEFT_wg4-IApgEYrX5bHFIZH7Ro40oDYGs=@protonmail.com>
[-- Attachment #1.1.1: Type: text/plain, Size: 1275 bytes --]
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
> #define PAGESIZE __PAGESIZE
> #define PAGE_SIZE PAGESIZE
>
> 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)) { ... }
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 2485 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 665 bytes --]
next prev parent reply other threads:[~2023-02-15 13:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-15 9:38 w6b7rk5yu4mt25v3
2023-02-15 9:43 ` w6b7rk5yu4mt25v3
2023-02-15 10:32 ` Corinna Vinschen
2023-02-15 11:14 ` Fw: " w6b7rk5yu4mt25v3
2023-02-15 12:13 ` Corinna Vinschen
2023-02-15 12:40 ` w6b7rk5yu4mt25v3
2023-02-15 13:02 ` Oskar Skog [this message]
2023-02-15 15:31 ` Fw: " w6b7rk5yu4mt25v3
2023-02-15 16:33 ` Corinna Vinschen
2023-02-15 17:20 ` [EXTERNAL] " Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2023-02-19 13:08 ` w6b7rk5yu4mt25v3
2023-02-19 15:40 ` Fw: " w6b7rk5yu4mt25v3
2023-02-15 13:41 ` Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d594b5d0-8810-c752-97ff-a28b2524552f@oskog97.com \
--to=oskar@oskog97.com \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).