Hacker News new | ask | show | jobs
by aidenn0 2485 days ago
brk() is undefined behavior if mmap is ever called.
4 comments

I was wrong, it's only if you use MAP_FIXED to map an overlapping area.
How so? Both syscalls are invoked pretty frequently together in the same program.
Wow that's news to me - can you point me at the documentation for that?
Can you post a definite source supporting this?
There isn't one, because it's wrong.

Source: run strace on almost any useful Linux command (e.g. ls, sort, which, ...), you'll see it makes calls to both brk() and mmap().

The OP admitted it was wrong, but just because everyone does it doesn't mean it's not undefined behavior.