stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: test for lib.alg.sort
Date Wed, 08 Feb 2006 01:49:29 GMT
Anton Pevtsov wrote:
> Martin Sebor wrote:
> 
>> <>> It looks to me like the sort and stable_sort tests are completel
> 
> 
>> <>independent of the partial sort tests, correct? If that's so, could you
>> please split the test into two? It will make them easier to >
>> maintain and prevent errors in one from affecting the results of the
>> other.
> 
> 
> Yes, the attached files contains separated tests for sort and
> partial_sort algorithms.

Thank you! It's in:
http://svn.apache.org/viewcvs.cgi?rev=375776&view=rev

> 
> Martin Sebor wrote:
> 
>> <>[...]
> 
> 
>> <>> Here's a little program that should demonstrate what I mean. Note 
>> that
> 
> 
>> the replacement operator new and delete don't work across shared library
> 
> 
>> <>boundaries on AIX and Windows. It would be > nice to find an
>> equivalent solution that does work there (or at least on Windows). Some
>> kind of malloc() hook maybe -- any ideas?
>>
> Hmm, hooks seems to be a tricky and platform-dependent solution.

Replacement operator new and delete are standard C++. That they don't
work across shared library boundaries on AIX and Windows is a limitation
(bug, IMO) of those platforms. The only reason why C++ compiler vendors
on those platforms get away it is because the standard fails to address
(even acknowledge) the existence of shared libraries.

> May be it is possible to add the "logged" (as in the test driver) new
> and delete operators into the library itself and switch to them using
> some define?

That wouldn't work. The replacement operators must not be inline and
they must be defined at most once in a program. What would work is
replacing all calls to these operators made by the library (within
.cpp files or headers) with a call to some library function and
providing a mechanism to hook into this function (e.g., a callback).

In fact, there already is a pair of functions kind of like that
(__rw_allocate() and __rw_deallocate()) although they aren't used
throughout the library. Though a change to make them used instead
of the remaining calls to new and delete would be pretty easy. It
would be a useful enhancement.

That said, there ought to be a non-invasive solution to the problem
besides replacing operators new and delete that we could employ in
the test driver. Some platforms provide hooks for debugging malloc.
MSVC has its _malloc_dbg() and _free_dbg() that we could use instead
(that would be a useful enhancement to rwt_checkpoint() and friends).
I don't know if there is something similar on AIX but if not, we might
just have to accept the fact that there might be platforms where we
can't do this kind of thing.

Martin

Mime
View raw message