Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

large mmap() with MAP_NORESERVE fails unless overcommit_memory is 1 #2784

Closed
zeux opened this issue Dec 23, 2017 · 3 comments
Closed

large mmap() with MAP_NORESERVE fails unless overcommit_memory is 1 #2784

zeux opened this issue Dec 23, 2017 · 3 comments
Assignees

Comments

@zeux
Copy link

zeux commented Dec 23, 2017

This came out of #121 where address sanitizer doesn't work out of the box under WSL, requiring setting /proc/sys/vm/overcommit_memory to 1. This is because asan tries to map a large memory region with MAP_NORESERVE and PROT_READ|PROT_WRITE and this map fails (curiously, mapping the region with PROT_NONE and doing a following mprotect succeeds).

This program:

#include <sys/mman.h>
#include <stdio.h>

int main()
{
	size_t size = 0xdfff0001000;

	void* ptr = mmap(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0);
	printf("mmap => %p\n", ptr);
}

Prints a valid pointer on a real Linux system with overcommit_memory set to 0. Under WSL, mmap returns -1. Setting overcommit_memory to 1 fixes this but the expected behavior is that this code works without changes under WSL.

@zeux zeux mentioned this issue Dec 23, 2017
@jstarks jstarks self-assigned this Dec 30, 2017
@jstarks
Copy link
Member

jstarks commented Dec 30, 2017

This should be simple to fix.

@benhillis
Copy link
Member

Fixed in 17093.

@zeux
Copy link
Author

zeux commented Mar 30, 2018

Confirmed - this is fixed in 17127.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants