Jacques Caron jc at oxado.com
Thu Jun 12 06:18:47 PDT 2008
Hi,

At 14:40 12/06/2008, Cyril SCETBON wrote:
>I've tested it on the host and did not get any error with a negative 
>value or a big value :
>
>cat test_malloc.c
>
>#include <stdlib.h>
>#include <stdio.h>
>
>int main()
>{
>        printf("malloc(-4096)\n");
>        malloc(-4096);
>        printf("malloc(18446744073709547520)\n");
>        malloc(18446744073709547520);
>        return 0;
>}
>
>cc -g -w test_malloc.c -o test_malloc
>
>./test_malloc
>malloc(-4096)
>malloc(18446744073709547520)
>
>no segmentation fault

Quite normal, the malloc itself won't cause a segfault, it's the fact 
that something later uses space requested via malloc that couldn't be 
allocated (malloc then returned 0). What's the return value of the 
malloc calls?

>, and the strace command shows :
>
>write(1, "malloc(-4096)\n", 14malloc(-4096)
>)         = 14
>brk(0)                                  = 0x501000
>brk(0x521000)                           = 0x521000
>mmap(NULL, 2097152, PROT_NONE, 
>MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x2b78f91d1000
>munmap(0x2b78f91d1000, 192512)          = 0
>munmap(0x2b78f9300000, 856064)          = 0
>mprotect(0x2b78f9200000, 131072, PROT_READ|PROT_WRITE) = 0
>mmap(NULL, 2097152, PROT_NONE, 
>MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x2b78f9300000
>munmap(0x2b78f9400000, 1048576)         = 0
>mprotect(0x2b78f9300000, 131072, PROT_READ|PROT_WRITE) = 0
>munmap(0x2b78f9300000, 1048576)         = 0
>write(1, "malloc(18446744073709547520)\n", 29malloc(18446744073709547520)
>) = 29
>mmap(NULL, 2097152, PROT_NONE, 
>MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x2b78f9300000
>munmap(0x2b78f9400000, 1048576)         = 0
>mprotect(0x2b78f9300000, 131072, PROT_READ|PROT_WRITE) = 0
>munmap(0x2b78f9300000, 1048576)         = 0
>munmap(0x2b78f8e94000, 4096)            = 0
>exit_group(0)                           = ?
>Process 15518 detached

- you'll notice that the mmap calls are the same for both calls 
(don't quite know what malloc is really doing here, it seems to be 
allocating more space then freeing up bits, probably trying to align 
on some large size), though neither size matches the actual request (?)

- the malloc-induced mmap is quite different from the one in your 
original strace (see the flags). Is that the same box? You must have 
some special compile flags or libraries in your slonik compile that 
change malloc's behaviour. Was your slony-1 install locally compiled 
or installed from binaries? If the latter you might want to try a 
good old wget/tar/configure/make to see if the result is the same...

Jacques.



More information about the Slony1-general mailing list