public inbox for cygwin-developers@cygwin.com
 help / color / mirror / Atom feed
From: w6b7rk5yu4mt25v3 <w6b7rk5yu4mt25v3@protonmail.com>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>,
	"cygwin-developers@cygwin.com" <cygwin-developers@cygwin.com>
Subject: Why do these mprotect always fail?
Date: Wed, 15 Feb 2023 09:38:04 +0000	[thread overview]
Message-ID: <yxifinJpR7DQ4XDFwpYMrUknNpsg8wu5T1KYPeNIwjf3FL_lYou0whmzg-XCoFgYlcz96k0yEjkrxCOQOOTztnk_tvW7ZNi8_riHbsOn-ZU=@protonmail.com> (raw)

mprotect 1:

    unsigned char* buffer;
    int32_t available, size;

      if(size > PAGE_SIZE) {
        factor = size / PAGE_SIZE + 1;
      }
      available = factor * PAGE_SIZE;

      if(posix_memalign((void**)&buffer, PAGE_SIZE, available)) {
        std::wcerr << L"Unable to allocate JIT memory!" << std::endl;
        exit(1);
      }
      if(mprotect(buffer, available, PROT_READ | PROT_WRITE | PROT_EXEC) < 0) {
        std::wcerr << L"Unable to mprotect" << std::endl;
        exit(1);
      }

mprotect 2:

  if(posix_memalign((void**)& buffer, PAGE_SIZE, PAGE_SIZE)) {
    std::wcerr << L"Unable to allocate JIT memory!" << std::endl;
    exit(1);
  }

  if(mprotect(buffer, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC) < 0) {
    std::wcerr << L"Unable to mprotect" << std::endl;
    exit(1);
  }


Sent with Proton Mail secure email.

             reply	other threads:[~2023-02-15  9:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-15  9:38 w6b7rk5yu4mt25v3 [this message]
2023-02-15  9:43 ` w6b7rk5yu4mt25v3

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='yxifinJpR7DQ4XDFwpYMrUknNpsg8wu5T1KYPeNIwjf3FL_lYou0whmzg-XCoFgYlcz96k0yEjkrxCOQOOTztnk_tvW7ZNi8_riHbsOn-ZU=@protonmail.com' \
    --to=w6b7rk5yu4mt25v3@protonmail.com \
    --cc=cygwin-developers@cygwin.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).