X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E95FA385842A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1676453916; bh=ZXtzXMHu9N5nFrVyquudG/NicNkyEnDdP1ciPxT44vw=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=DnEQzagbjd7TiBjVDZ/1NAbhLUQbp8xTpikGZRjRC3AKsMEhvNAufqAgmf+zNauy1 sgszAiDGDT+Wa6JHLnsNcsLnw3atT1j2NMDZtpZS1AXuTlrgtWSurkgiLDExzzev0L vogh1ftu5x6eQvxk1UAzaO43bT7TuUoIRExST5R4= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 41E6A3858D33 Date: Wed, 15 Feb 2023 09:38:04 +0000 To: "cygwin AT cygwin DOT com" , "cygwin-developers AT cygwin DOT com" Subject: Why do these mprotect always fail? Message-ID: Feedback-ID: 67221101:user:proton MIME-Version: 1.0 X-Spam-Status: No, score=-2.4 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 List-Archive: List-Post: List-Help: List-Subscribe: , From: w6b7rk5yu4mt25v3 via Cygwin Reply-To: w6b7rk5yu4mt25v3 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Cygwin" 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