October 2018
Beginner
794 pages
19h 23m
English
So, how do you know where the current program break is? That's easy – the sbrk(3) API, when used with a parameter value of zero, returns the current program break! Let's do a quick lookup:
#include <unistd.h>[...] printf("Current program break: %p\n", sbrk(0));
You will see some sample output as follows when the preceding line of code runs:
$ ./show_curbrk Current program break: 0x1bb4000$ ./show_curbrk Current program break: 0x1e93000$ ./show_curbrk Current program break: 0x1677000$
It works, but why does the program break value keep changing (seemingly randomly)? Well, it really is random: for security reasons, Linux randomizes the layout of a process's virtual address space (we covered the process VAS layout in
Read now
Unlock full access