[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ltdl.c thinks it's psychic (another SEGFAULT bug).

From: libtool
Subject: Re: ltdl.c thinks it's psychic (another SEGFAULT bug).
Date: Sat, 10 Nov 2001 11:17:10 -0600
User-agent: Mutt/1.2.5i

On Wed, Nov 07, 2001 at 12:39:32AM -0600, Rob Browning wrote:
> address@hidden writes:
> > So, if we replace malloc, we then need a table of pointers and their
> > size. Worth it?
> If we're going to be using it for anything substantial, I tend to
> think this would be *extremely* unwise.  Writing a good allocator is
> *hard*.
> If the performance is critical, then I suspect we should use the
> system realloc if/when we can determine (via that it's
> reliable, and otherwise, we should be using more explicit means.
> Using gnu libc's realloc certainly would have worked better in my
> case.
> Anyway from a quick glance, it looks like we're only using realloc for
> strings, which you can easily determine the length of, and for
> lt_caller_data which could be easily augmented to include a size
> field.
> So as one approach, we could just have str_realloc() and
> realloc_caller_data(), and then these could use the system realloc
> internally on platforms where that's considered beneficial.

According to ltdl.h,
/* By default, the realloc function pointer is set to our internal
   realloc implementation which iself uses lt_dlmalloc and lt_dlfree.
   libltdl relies on a featureful realloc, but if you are sure yours
   has the right semantics then you can assign it directly.  Generally,
   it is safe to assign just a malloc() and a free() function.  */

And, in ltdl.c:
/* These are the pointers that can be changed by the caller:  */
LT_GLOBAL_DATA lt_ptr (*lt_dlmalloc)    LT_PARAMS((size_t size))
                        = (lt_ptr (*) LT_PARAMS((size_t))) malloc;
LT_GLOBAL_DATA lt_ptr (*lt_dlrealloc)   LT_PARAMS((lt_ptr ptr, size_t size))
                        = (lt_ptr (*) LT_PARAMS((lt_ptr, size_t))) rpl_realloc;
LT_GLOBAL_DATA void   (*lt_dlfree)      LT_PARAMS((lt_ptr ptr))
                        = (void (*) LT_PARAMS((lt_ptr))) free;

Because ltdl.h already states that libltdl relies on a featureful
realloc, let's just set lt_dlrealloc = realloc and test for a
featureful realloc in ltdl.m4. Let's recommend that if anyone changes
at least one of lt_dlmalloc, lt_dlrealloc, or lt_dlfree, then they
should also change them all. Let the client worry about malloc/free
and ltdl be somewhat stupid to the choices of the client.

albert chin (address@hidden)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]