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 <w6b7rk5yu4mt2...@protonmail.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