Re: [9fans] memory woes - Plan9

This is a discussion on Re: [9fans] memory woes - Plan9 ; libpool writes a magic byte at the end of the allocation. if this is not present when memory is free'd, libpool assumes you've corrupted memory and aborts. - erik On Fri Jan 5 09:52:13 EST 2007, sretzki@gmx.de wrote: > > ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Re: [9fans] memory woes

  1. Re: [9fans] memory woes

    libpool writes a magic byte at the end of the allocation. if this is not present
    when memory is free'd, libpool assumes you've corrupted memory and aborts.

    - erik

    On Fri Jan 5 09:52:13 EST 2007, sretzki@gmx.de wrote:
    > > you are forgetting +1 for the null. you need strlen("Hello World")+1.

    >
    > Heh! Yeah, true. But then the strcpy() would write into non-allocated area, so why does the free()-call make it crash?


  2. Re: [9fans] memory woes

    erik quanstrom wrote:
    > libpool writes a magic byte at the end of the allocation. if this is not present
    > when memory is free'd, libpool assumes you've corrupted memory and aborts.


    And other malloc implementations might store some important internal
    information (block size, typically) there, which if corrupted can make
    any subsequent malloc/realloc/calloc/free call run amok.

+ Reply to Thread