http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59733

--- Comment #17 from Kostya Serebryany <kcc at gcc dot gnu.org> ---
When I look at my /proc/PID/maps of cc1plus, I see this: 

...
610000000000-610000030000 rw-p 00000000 00:00 0 
610000030000-611000000000 ---p 00000000 00:00 0 
611000000000-611000980000 rw-p 00000000 00:00 0 
611000980000-612000000000 ---p 00000000 00:00 0 
612000000000-6120001b0000 rw-p 00000000 00:00 0 
6120001b0000-613000000000 ---p 00000000 00:00 0 
613000000000-613000370000 rw-p 00000000 00:00 0 
613000370000-614000000000 ---p 00000000 00:00 0 
614000000000-6140001a0000 rw-p 00000000 00:00 0 
6140001a0000-615000000000 ---p 00000000 00:00 0 
615000000000-615000460000 rw-p 00000000 00:00 0 
...
As you can see, there are no adjacent mappings with same perms. 

Here is a tiny test:

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
int main() {
  static volatile void *x;
  for (int i = 0; i < 1000000; i++)
    x = malloc(1000);
  printf("PID %d\n", getpid());
  sleep(100);
}

% clang -fsanitize=address nmalloc.c ; ./a.out 

The mapping at the end looks like this:
...
2008fff7000-10007fff8000 rw-p 00000000 00:00 0 
600000000000-619000000000 ---p 00000000 00:00 0 
619000000000-61904c4c0000 rw-p 00000000 00:00 0 
61904c4c0000-640000000000 ---p 00000000 00:00 0 
640000000000-640000003000 rw-p 00000000 00:00 0 
7f434fff7000-7f434fffb000 rw-p 00000000 00:00 0 
...
Note: only 4 mappings that start with 6.

I bet that on your OS this test will fail under asan; please check.

I don't know what makes Linux behave this way, we haven't seen it before.

Reply via email to