Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

brk() is undefined behavior if mmap is ever called.


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.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: