delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2023/02/15/04:44:53

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F00C3858C66
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1676454251;
bh=EOIMzbT1asXEoT3GfPfASDTY4gcRBbPDwGPjTHxk3GE=;
h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
From;
b=WRv/sOMD2qSk039xDj+Ck30I+4eAvJGDqJNJ1wvTfFUdbH9IkUUJ3JIKCN49PRiw1
huDfLqfggdpBlkTBm3ZWXUqpKqG286VQpG2FxTKISHA1RZAJPDbamz0AGYVJQlfaiW
xYkPZPWiOzufdbgHv8x3QT9yL9pwZfyW1yGnLSWI=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DB7FB3858D35
Date: Wed, 15 Feb 2023 09:43:10 +0000
To: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>,
"cygwin-developers AT cygwin DOT com" <cygwin-developers AT cygwin DOT com>
Subject: Re: Why do these mprotect always fail?
Message-ID: <ruVqVpKyYTyh3m-4mzaAg2pyhJAqlamcbUYKB8ghh_LwAKIqpabv0LNqlt8_Owfzx0Hc6c1C6nJE4Czf4hod2ukAWe3b6p_WAaaGLPk7CI8=@protonmail.com>
In-Reply-To: <yxifinJpR7DQ4XDFwpYMrUknNpsg8wu5T1KYPeNIwjf3FL_lYou0whmzg-XCoFgYlcz96k0yEjkrxCOQOOTztnk_tvW7ZNi8_riHbsOn-ZU=@protonmail.com>
References: <yxifinJpR7DQ4XDFwpYMrUknNpsg8wu5T1KYPeNIwjf3FL_lYou0whmzg-XCoFgYlcz96k0yEjkrxCOQOOTztnk_tvW7ZNi8_riHbsOn-ZU=@protonmail.com>
Feedback-ID: 67221101:user:proton
MIME-Version: 1.0
X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT,
FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS,
TXREP autolearn=ham autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: w6b7rk5yu4mt25v3 via Cygwin <cygwin AT cygwin DOT com>
Reply-To: w6b7rk5yu4mt25v3 <w6b7rk5yu4mt25v3 AT protonmail DOT com>
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

Almost forgot, PAGE_SIZE is set to 4096. This is a Linux application, when I compile on Cygwin it complained that PAGE_SIZE is redefined but the compilation was success nevertheless. Only when I run the application, I always exited with "Unable to mprotect".

Sent with Proton Mail secure email.

------- Original Message -------
On Wednesday, February 15th, 2023 at 16:38, w6b7rk5yu4mt25v3 <w6b7rk5yu4mt25v3 AT protonmail DOT com> wrote:


> 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.

-- 
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019