I created a simple C program and every time I load it in GDB, I see the same memory addresses allocated to the instructions of the program. For example, a function what() always loads at memory location 0x000055555555472d. In fact the stack is exactly the same for each execution(Not just the content of stack but the memory address which rsp points to.

I understand that ASLR can be disabled in Linux by setting "/proc/sys/kernel/randomize_va_space" to 0 but my Debian system has value 2 in it.

root@Sierra ~ % cat /proc/sys/kernel/randomize_va_space 

According to my understanding of ASLR, these addresses should be randomized at each run. My question is why is this happening? Did I get something wrong?

2 Answers 2


By default, gdb disables address space randomization on Linux, overriding whatever value the kernel.randomize_va_space sysctl variable may have.

The gdb command set disable-randomization off will turn this feature off, and any debugging targets created by gdb afterwards will have ASLR either on or off depending on the value of kernel.randomize_va_space.


How was the program compiled? On a Centos 7 system given blah.c and with the development foo installed

#include <stdio.h>

int whereisthis(void) { return 42; }

int main(void) {
    printf("%p\n", whereisthis);
    return 0;

the address of whereisthis can depend on the compile flags

% rm blah
% CFLAGS='-pipe' make blah
cc -pipe    blah.c   -o blah
% repeat 3 ./blah
% rm blah
% CFLAGS='-fstack-protector-all -fPIE -pie -pipe' make blah
cc -fstack-protector-all -fPIE -pie -pipe    blah.c   -o blah
% repeat 3 ./blah

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.