calloc interposing issue

R

reachanil

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
 
N

Nick Keighley

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
 
N

Nick Keighley

sorry for previous message. hit the wrong key

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>
 
R

Richard Heathfield

Nick Keighley said:
sorry for previous message. hit the wrong key



not sure what "interposed" means...

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

<snip>
 
R

Richard Tobin

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
 
M

Martin Vuille

(e-mail address removed) wrote in
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
 
F

Flash Gordon

Nick Keighley wrote, On 22/02/08 10:47:
On 22 Feb, 10:30, (e-mail address removed) wrote:


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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top