calloc interposing issue

Discussion in 'C Programming' started by reachanil@gmail.com, Feb 22, 2008.

  1. Guest

    Hi,

    We've interposed malloc/calloc/realloc/memalign/valloc in our
    application. While all of our application calls our own implementation
    of these functions, there seems to be some issue with the dl.so shared
    library (Windriver, ppc, linux 32 bit). The dl.so library defines a
    function called - _dl_tls_setup and another one - _dl_deallocate_tls.
    When our application that linked in -ldl and -lpthread, was shutting
    down, we saw a crash with the backtrace pointing to
    _dl_deallocate_tls. Upon further investigation we found that
    _dl_tls_deallocate was calling 'free' which was our own implementation
    (Not libc's) However, the chunk was got using malloc/calloc from
    libc!!!!!. I put a breakpoint at _dl_tls_setup and found that it was
    getting memory from the libc calloc.

    I'm not sure how the dl library could have got calloc from libc and
    free from our application. Please help!!!

    thanks,
    -Anil
    , Feb 22, 2008
    #1
    1. Advertising

  2. On 22 Feb, 10:30, wrote:
    > Hi,
    >
    > We've interposed malloc/calloc/realloc/memalign/valloc in our
    > application. While all of our application calls our own implementation
    > of these functions, there seems to be some issue with the dl.so shared
    > library (Windriver, ppc, linux 32 bit). The dl.so library defines a
    > function called - _dl_tls_setup and another one - _dl_deallocate_tls.
    > When our application that linked in -ldl and -lpthread, was shutting
    > down, we saw a crash with the backtrace pointing to
    > _dl_deallocate_tls. Upon further investigation we found that
    > _dl_tls_deallocate was calling 'free' which was our own implementation
    > (Not libc's) However, the chunk was got using malloc/calloc from
    > libc!!!!!. I put a breakpoint at _dl_tls_setup and found that it was
    > getting memory from the libc calloc.
    >
    > I'm not sure how the dl library could have got calloc from libc and
    > free from our application. Please help!!!
    >
    > thanks,
    > -Anil
    Nick Keighley, Feb 22, 2008
    #2
    1. Advertising

  3. sorry for previous message. hit the wrong key

    On 22 Feb, 10:30, wrote:

    > We've interposed malloc/calloc/realloc/


    not sure what "interposed" means...

    > memalign/valloc


    I'm not familiar with these. Are they new to C99?


    > in our
    > application. While all of our application calls our own implementation
    > of these functions,


    I'm pretty sure that puts you firmly in implementation defined
    territory.
    I don't think you can (portable) redefine standard library functions.


    > there seems to be some issue with the dl.so shared
    > library (Windriver, ppc, linux 32 bit).


    thats *really* implementaion defined! You need to try
    a windows programming news group

    <snip>


    --
    Nick Keighley
    Nick Keighley, Feb 22, 2008
    #3
  4. Nick Keighley said:

    > sorry for previous message. hit the wrong key
    >
    > On 22 Feb, 10:30, wrote:
    >
    >> We've interposed malloc/calloc/realloc/

    >
    > not sure what "interposed" means...


    "Interpositioning" means "replacing a library routine (typically but not
    necessarily a standard library function) with your own function".

    <snip>

    --
    Richard Heathfield <http://www.cpax.org.uk>
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999
    Richard Heathfield, Feb 22, 2008
    #4
  5. In article <>,
    <> wrote:

    >I'm not sure how the dl library could have got calloc from libc and
    >free from our application. Please help!!!


    You really need to ask about this on a group related to Linux;
    this stuff is very OS-dependent.

    -- Richard

    --
    :wq
    Richard Tobin, Feb 22, 2008
    #5
  6. wrote in
    news:
    ps.com:

    >
    > I'm not sure how the dl library could have got calloc from
    > libc and free from our application. Please help!!!
    >


    Perhaps enabling debug logging for the dynamic loader
    might help you determine how/why the symbols are being
    bound the way they are.

    Assuming Linux, man ld.so, LD_DEBUG.

    MV

    --
    I do not want replies; please follow-up to the group.
    Martin Vuille, Feb 22, 2008
    #6
  7. Flash Gordon Guest

    Nick Keighley wrote, On 22/02/08 10:47:
    > On 22 Feb, 10:30, wrote:


    <snip>

    >> there seems to be some issue with the dl.so shared
    >> library (Windriver, ppc, linux 32 bit).

    >
    > thats *really* implementaion defined!


    As far as the standard is concerned it is undefined, so the
    implementation may well not define it. In this case though I believe
    that Linux does provide mechanisms to do this.

    > You need to try
    > a windows programming news group


    I think you meant Linux programming group.
    --
    Flash Gordon
    Flash Gordon, Feb 22, 2008
    #7
    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. Andrey Tarasevich
    Replies:
    0
    Views:
    464
    Andrey Tarasevich
    Sep 2, 2003
  2. Kevin Goodsell
    Replies:
    0
    Views:
    481
    Kevin Goodsell
    Sep 2, 2003
  3. luca
    Replies:
    5
    Views:
    26,926
    Default User
    Mar 2, 2004
  4. JKop

    calloc.... Why?

    JKop, Jul 18, 2004, in forum: C++
    Replies:
    14
    Views:
    771
    tom_usenet
    Jul 20, 2004
  5. Jun Woong

    Re: Override malloc,calloc,realloc and free?

    Jun Woong, Jun 26, 2003, in forum: C Programming
    Replies:
    0
    Views:
    1,061
    Jun Woong
    Jun 26, 2003
Loading...

Share This Page