Cyril SCETBON scetbon at echo.fr
Mon Jun 16 06:22:44 PDT 2008

Jacques Caron wrote:
> 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?
malloc returns NULL in the both cases
>
>> , 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 (?)
ok
>
> - the malloc-induced mmap is quite different from the one in your 
> original strace (see the flags). Is that the same box? 
It's the same host
> 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?
packaged (debian) from sources :

cc -g -Wall -O2 -Wall -Wmissing-prototypes -Wmissing-declarations 
-I../.. -DPGSHARE="\"/usr/share/slony1\""  -I/usr/incl
ude/postgresql/8.2/server/ -I/usr/include/postgresql/  -c -o slonik.o 
slonik.c
cc -g -Wall -O2 -Wall -Wmissing-prototypes -Wmissing-declarations 
-I../.. -DPGSHARE="\"/usr/share/slony1\""  -I/usr/incl
ude/postgresql/8.2/server/ -I/usr/include/postgresql/  -c -o dbutil.o 
dbutil.c
cc -g -Wall -O2 -Wall -Wmissing-prototypes -Wmissing-declarations 
-I../.. -DPGSHARE="\"/usr/share/slony1\""  -I/usr/incl
ude/postgresql/8.2/server/ -I/usr/include/postgresql/  -c -o parser.o 
parser.c
> If the latter you might want to try a good old wget/tar/configure/make 
> to see if the result is the same...
>
> Jacques.
>

-- 
Cyril SCETBON - Ingénieur bases de données
AUSY pour France Télécom - OPF/PORTAILS/DOP/HEBEX

Tél : +33 (0)4 97 12 87 60
Jabber : cscetbon at jabber.org
France Telecom - Orange
790 Avenue du Docteur Maurice Donat 
Bâtiment Marco Polo C2 - Bureau 202
06250 Mougins
France

***********************************
Ce message et toutes les pieces jointes (ci-apres le 'message') sont
confidentiels et etablis a l'intention exclusive de ses destinataires.
Toute utilisation ou diffusion non autorisee est interdite.
Tout message electronique est susceptible d'alteration. Le Groupe France
Telecom decline toute responsabilite au titre de ce message s'il a ete
altere, deforme ou falsifie.
Si vous n'etes pas destinataire de ce message, merci de le detruire
immediatement et d'avertir l'expediteur.
***********************************
This message and any attachments (the 'message') are confidential and
intended solely for the addressees.
Any unauthorised use or dissemination is prohibited.
Messages are susceptible to alteration. France Telecom Group shall not be
liable for the message if altered, changed or falsified.
If you are not recipient of this message, please cancel it immediately and
inform the sender.
************************************



More information about the Slony1-general mailing list