# On g++-sjlj.exe (GCC) 4.2.1-sjlj (mingw32 sjlj-unwind) # g++ -v Using built-in specs. Target: mingw32 Configured with: ../gcc-4.2.1/configure --with-gcc --enable-libgomp --host=mingw32 --build=mingw32 --target=mingw32 --program-suffix=-sjlj --with-arch=i486 --with-tune=generic --disable-werror --prefix=/mingw --with-local-prefix=/mingw --enable-threads --disable-nls --enable-languages=c,c++,fortran,objc,obj-c++,ada --disable-win32-registry --enable-sjlj-exceptions --enable-libstdcxx-debug --enable-cxx-flags=-fno-function-sections -fno-data-sections --enable-version-specific-runtime-libs --disable-bootstrap Thread model: win32 gcc version 4.2.1-sjlj (mingw32 sjlj-unwind) # And # On g++ (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) // sjlj-EH # g++ -v Configured with: /usr/build/package/orig/test.respin/gcc-3.4.4-3/configure --verbose --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-languages=c,ada,c++,d,f77,pascal,java,objc --enable-nls --without-included-gettext --enable-version-specific-runtime-libs --without-x --enable-libgcj --disable-java-awt --with-system-zlib --enable-interpreter --disable-libgcj-debug --enable-threads=posix --enable-java-gc=boehm --disable-win32-registry --enable-sjlj-exceptions --enable-hash-synchronization --enable-libstdcxx-debug Thread model: posix gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) -------------------------------------------------------------
The test case below shows that Gcc sjlj exception handling corrupts stack and can make the process crash when the stack frame contains VLA(variable length array) or alloca()'ed variables and has no catch handler for the exception being handled. And this is my solution for this bug ==> http://home.paran.com/darkxun/libcyn/GccBugFix.html I'm not offending you guys. Just wanted to make a prof that it is my own work (not plagiarized). Sorry. <problem.cc>------------------------------------------------- #include <stdio.h> static int __seq = 0; struct Temp { int _i; Temp() : _i(__seq++) { fprintf(stderr,"%d\n", _i); } virtual ~Temp() { fprintf(stderr,"%d\n", _i); } }; void problem( void(*func)() ) { int N=5; Temp temp[N]; func(); } <main.cc>---------------------------------------------------- void problem( void(*func)() ); void bugger() { throw "anything"; } int main() { try { problem( bugger ); } catch(...) {} } <compilation>------------------------------------------------ #using static problem.o g++ -o problem.o problem.cc -c g++ main.cc problem.o #or shared problem.dll g++ -o problem.dll problem.cc -shared g++ main.cc problem.dll -- Summary: (cygwin/mingw) sjlj exception handling corrupts stack Product: gcc Version: 4.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: darkxun at paran dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33874