free and abort

Discussion in 'C Programming' started by jois.de.vivre@gmail.com, Jun 6, 2007.

  1. Guest

    I have some code that, after some time, crashes with an abort signal
    (signal 6). Upon examining the core dump it would seem that the
    signal originates at free(). I have read the documentation but I
    cannot find anything that talks about free() ever throwing a signal.
    Is this non-standard behavior from gcc?
    , Jun 6, 2007
    #1
    1. Advertising

  2. Ben Pfaff Guest

    writes:

    > I have some code that, after some time, crashes with an abort signal
    > (signal 6). Upon examining the core dump it would seem that the
    > signal originates at free(). I have read the documentation but I
    > cannot find anything that talks about free() ever throwing a signal.


    Probably, your code yields undefined behavior by overwriting some
    of the bookkeeping data that malloc and related functions
    maintain. Look carefully through your code to check that it does
    not write beyond the boundaries of allocated data blocks, or try
    using a memory debugger such as Valgrind.

    > Is this non-standard behavior from gcc?


    GCC doesn't implement the standard C library; that's left to
    external software, such as glibc. But it's not unusual for a C
    library to abort when its bookkeeping data becomes corrupted.
    --
    "...what folly I commit, I dedicate to you."
    --William Shakespeare, _Troilus and Cressida_
    Ben Pfaff, Jun 6, 2007
    #2
    1. Advertising

  3. Tor Rustad Guest

    wrote:

    > I have some code that, after some time, crashes with an abort signal
    > (signal 6). Upon examining the core dump it would seem that the
    > signal originates at free(). I have read the documentation but I
    > cannot find anything that talks about free() ever throwing a signal.


    My guess would be that you somewhere call free() with invalid input, that
    invoke UB, in that case the implementation is free to do whatever it wants.

    I support Ben's advice, by using a tool, such as valgrind or eletric fence.

    --
    Tor <torust [at] online [dot] no>
    Tor Rustad, Jun 6, 2007
    #3
  4. Al Balmer Guest

    On Wed, 06 Jun 2007 18:02:31 -0000, wrote:

    >I have some code that, after some time, crashes with an abort signal
    >(signal 6). Upon examining the core dump it would seem that the
    >signal originates at free(). I have read the documentation but I
    >cannot find anything that talks about free() ever throwing a signal.
    >Is this non-standard behavior from gcc?


    Well, it's not Standard behavior <g>. You're probably passing free()
    an address which doesn't point to an allocated block. First guess -
    you're freeing the same pointer twice.

    --
    Al Balmer
    Sun City, AZ
    Al Balmer, Jun 6, 2007
    #4
  5. <> wrote in message
    news:...
    >I have some code that, after some time, crashes with an abort signal
    > (signal 6). Upon examining the core dump it would seem that the
    > signal originates at free(). I have read the documentation but I
    > cannot find anything that talks about free() ever throwing a signal.
    > Is this non-standard behavior from gcc?
    >

    What tends to happen is that you corrupt some memory allocated by malloc(),
    and the sytem detects it at the point where you call free().
    Once you have ordered an illegal operation, as far as the standard is
    concerned the rest of the program's behaviour is completely undefined. This
    includes a distantly-related free() throwing a signal.
    --
    Free games and programming goodies.
    http://www.personal.leeds.ac.uk/~bgy1mm
    Malcolm McLean, Jun 7, 2007
    #5
  6. <> schrieb im Newsbeitrag
    news:...
    >I have some code that, after some time, crashes with an abort signal
    > (signal 6). Upon examining the core dump it would seem that the
    > signal originates at free(). I have read the documentation but I
    > cannot find anything that talks about free() ever throwing a signal.
    > Is this non-standard behavior from gcc?

    most likely you pass something to free() that hadn't been returned from
    [cm]alloc() or you called free() twice with the same parameter.

    Bye, Jojo
    Joachim Schmitz, Jun 7, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jim
    Replies:
    0
    Views:
    667
  2. David
    Replies:
    11
    Views:
    621
    David
    Nov 8, 2005
  3. george
    Replies:
    0
    Views:
    1,076
    george
    Aug 29, 2008
  4. mohammed_a_o
    Replies:
    0
    Views:
    255
    mohammed_a_o
    Nov 30, 2010
  5. Jazzis
    Replies:
    2
    Views:
    231
    Jazzis
    Sep 23, 2003
Loading...

Share This Page