what does `munmap` on Linux do when address is set to 0? Somehow this succeeds on Linux but fails on FreeBSD. I'm assuming the semantics are different but cannot find any reference regarding to such behavior.
@PeterCxy Read the Linux kernel source code
@niconiconi nah i have already read it and solved the issue. Now I'm trying to figure out why I'm getting INVALID_OPCODE when I should be getting page faults...
@PeterCxy according to the posix spec https://pubs.opengroup.org/onlinepubs/009695399/functions/munmap.html the behaviour depends entirely on what the OS considers "the valid range for the address space of a process" to be.
Apparently you can mmap something at address 0 in linux as long as it's not disallowed through the setting of /proc/sys/vm/mmap_min_addr (You can't use posix mmap to do that, i guess you need to do syscalls directly). There's an old ML thread about it: https://yarchive.net/comp/linux/address_zero.html
The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!