Original Post
I don't know if I'm doing something really stupid (I'm a noob), but I'm having a problem with exceptions that's driving me absolutely insane. [sad] I'm using SWIG to make a Python module in C++. I have GCC 4.1.1. Now, here's a little snippet of code: I compile this with and eventually out comes a file called _libtrafsim.so. So I import it in Python (2.4.3), and try this function out. [sad] Here's what Valgrind tells me: Any clues as to what the deal might be, or what steps I can take to investigate further? [Edited by - twix on August 5, 2006 3:23:30 AM]
void exTest()
{
try
{
throw 1;
}
catch (int n)
{
std::cerr << "Yay!\n";
}
}
g++ -I/usr/include/python2.4 -O0 -g3 -Wall -c -fmessage-length=0 -fPIC
>>> import libtrafsim
>>> libtrafsim.exTest()
*** glibc detected *** free(): invalid pointer: 0xb7c86668 ***
Aborted
>>> import libtrafsim
>>> libtrafsim.exTest()
==10646==
==10646== Invalid free() / delete / delete[]
==10646== at 0x401C029: free (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==10646== by 0x400E2AD: ___tls_get_addr (in /lib/ld-2.3.6.so)
==10646== by 0x48E542A: (within /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/libstdc++.so.6.0.8)
==10646== by 0x48E5466: __cxa_get_globals (in /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/libstdc++.so.6.0.8)
==10646== by 0x48E4F4E: __cxa_allocate_exception (in /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/libstdc++.so.6.0.8)
==10646== by 0x46A2BB4: TrafSim::exTest() (Serialization.cpp:39)
==10646== by 0x46ABAA1: _wrap_exTest (libtrafsim_wrap.cxx:2968)
==10646== by 0x408765A: PyCFunction_Call (in /usr/lib/libpython2.4.so.1.0)
==10646== Address 0x428E668 is not stack'd, malloc'd or (recently) free'd