problem with malloc() in a child-process ...

From: Marc Eilhard (marc.eilhard_at_forst.uni-goettingen.de)
Date: 08/30/04


Date: Mon, 30 Aug 2004 11:04:42 +0200

Hi there,

i have a problem with malloc() in a process.

Here is a snippet:

-----<snip>----------<snip>----------<snip>----------<snip>----------<snip>-----

      66 int io_send(int sock, IO_FLAG flag, const char* msg, int size)
      67 {
      68
      69 char* buf = NULL;
      70 fprintf(stderr, "sending ...\n" );
      71
      72 /* buf is as long as complete size (4 Bytes) + flag (4
Bytes) + data ( 'size' Bytes ) */
      73 int buf_size = size+9;
      74
      75 buf = (char*) malloc(buf_size);

-----<snip>----------<snip>----------<snip>----------<snip>----------<snip>-----

io_send is called out of a child-process. The first time it works fine but
after that

gdb says:

-----<snip>----------<snip>----------<snip>----------<snip>----------<snip>-----

76 buf = (char*) malloc(buf_size);
(gdb) n

Program received signal SIGSEGV, Segmentation fault.
0x4017bede in mallopt () from /lib/tls/libc.so.6

-----<snip>----------<snip>----------<snip>----------<snip>----------<snip>-----

here is the backtrace:

-----<snip>----------<snip>----------<snip>----------<snip>----------<snip>-----

(gdb) bt
#0 0x4017bede in mallopt () from /lib/tls/libc.so.6
#1 0x0804859f in ?? ()
#2 0x4011219c in ?? () from /lib/tls/libc.so.6
#3 0x69656c6b in ?? ()
#4 0x4023f888 in __after_morecore_hook () from /lib/tls/libc.so.6
#5 0xbffffab0 in ?? ()
#6 0x4023f840 in __after_morecore_hook () from /lib/tls/libc.so.6
#7 0x0804b048 in ?? ()
#8 0x00000050 in ?? ()
#9 0x4023f840 in __after_morecore_hook () from /lib/tls/libc.so.6
#10 0x4023eebc in ?? () from /lib/tls/libc.so.6
#11 0x4023f840 in __after_morecore_hook () from /lib/tls/libc.so.6
#12 0x00000001 in ?? ()
#13 0x00000045 in ?? ()
#14 0x4017b11d in malloc () from /lib/tls/libc.so.6
#15 0x4023f840 in __after_morecore_hook () from /lib/tls/libc.so.6
#16 0x00000045 in ?? ()
#17 0x00000000 in ?? ()
#18 0x40240190 in timezone () from /lib/tls/libc.so.6
#19 0xbffffab0 in ?? ()
#20 0xbffff9b8 in ?? ()
#21 0x080493b8 in io_send (sock=Cannot access memory at address 0x12
) at src/IOFunctions.cpp:76

-----<snip>----------<snip>----------<snip>----------<snip>----------<snip>-----

i am working with debian 3.0 and gcc 3.3.4

Any idea what is going wrong here ?

Thank you!

-- 
Marc Eilhard
Institut für Forstliche Biometrik und Informatik
Universität Göttingen
Büsgenweg 4, 37077 Göttingen
Tel.:     0551 39-12109
icq:      136978363


Relevant Pages

  • C/Ubuntu ][ Problem in Buffer Overflow logic
    ... Hi all, it's the first time I posto something here, i usually try to ... int ciao { ... Breakpoint 1 at 0x80483cc: file xploitable.c, ...
    (comp.lang.c)
  • Re: Firefox 3.5 crashes
    ... it coredumps shortly after drawing the screen. ... gdb says it's ... It's trying to display the "so you've upgraded and we want to annoy you ... But that only happens the first time you start it. ...
    (comp.unix.bsd.freebsd.misc)
  • Re: C compiler issue perhaps?
    ... through using the gdb n command. ... the first time i print it its zero. ...
    (freebsd-questions)
  • C compiler issue perhaps?
    ... I have a program I was testing with gdb. ... I was trying to figure out why c.rmonths was always zero when it should have been 6. ... the first time i print it its zero. ... The program is not compiled with any optimization. ...
    (freebsd-questions)