I've recently made a discovery concerning uClibc and C++ exceptions.
Really, my "throwcp" patch doesn't go far enough, for *all* functions,
including cancellation points and qsort() could be marked __THROW, leaving
uClibc no more broken than it is already.
The problem is that, for exceptions to pass through a function like
qsort(), as in the C++ example below:
-----8<-----
#include <stdlib.h>
#include <assert.h>
static int dummy_comparer(const void *,const void *)
{
throw 42;
}
char dummy_array[2] = {0, 0};
int main(int argc, char **argv)
{
try
{
qsort(dummy_array,2,1,&dummy_comparer);
}
catch (int ei)
{
assert(ei == 42);
return EXIT_SUCCESS;
}
abort();
}
-----8<-----
... it's not enough that the function not be mistakenly marked __THROW.
It is also essential that it be compiled with "-fexceptions", and that the
library be linked with crtbegin.o / crtend.o. As a result, the above
example will crash on uClibc.
However, the cure, which would mean bloating uClibc with exception tables
and linking with libgcc_s.so, seems worse than the disease.
(GCC supports a way to work with glibc's ld.so and binutils to allow a
library which throws no exceptions to carry exception tables without
linking libgcc_s. However, for some reason this is explicitly disabled
for uClibc, although it seems to have the "dl_iterate_phdr" function GCC
is using, and the rest of the heavy lifting is done by ld.)
---- Michael Deutschmann <[email protected]>
_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc