This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PATCH: Programs dump core when using -fsjlj-exceptions and share


The program included at the end of the message dumps core when compiled with any
GCC/EGCS version 1.1.2 and up under FreeBSD and OpenBSD. The reason why it does
that is because GCC fails to generate code which is responsible for restoring
proper value of the PIC(EBX) register at the builtin_setjmp recieve point.
Systeme which are using non-sjlj exceptions propagation are not affected by
the bug because proper code is already provided by the exception_receiver RTL
expansion. The following patch provides similar code for the
builtin_setjmp_receiver expansion and that fixes fixes the problem:

Index: config/i386/i386.md
===================================================================
RCS file: /home/ncvs/src/contrib/gcc/config/i386/i386.md,v
retrieving revision 1.5
diff -u -r1.5 i386.md
--- config/i386/i386.md 1999/11/15 04:28:55     1.5
+++ config/i386/i386.md 2000/01/16 04:21:02
@@ -8195,3 +8195,13 @@
   load_pic_register (1);
   DONE;
 }")
+
+(define_expand "builtin_setjmp_receiver"
+  [(label_ref (match_operand 0 "" ""))]
+  "flag_pic"
+  "
+{
+  load_pic_register (1);
+  DONE;
+}")
+

 
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#       .
#       ./runtest
#       ./runtest/Makefile
#       ./runtest/runtest.cpp
#       ./Makefile
#       ./libtest
#       ./libtest/Makefile
#       ./libtest/libtest.cpp
#       ./libtest/libtest.h
#
echo c - .
mkdir -p . > /dev/null 2>&1
echo c - ./runtest
mkdir -p ./runtest > /dev/null 2>&1
echo x - ./runtest/Makefile
sed 's/^X//' >./runtest/Makefile << 'END-of-./runtest/Makefile'
X# $FreeBSD: src/lib/libalias/Makefile,v 1.12 1999/08/27 23:58:00 peter Exp $
X
XPROG=          runtest
XSRCS=          runtest.cpp
XCC=             c++
XCFLAGS=         -g
XCXXFLAGS+=      -I../libtest
XLDFLAGS+=       -L../libtest -ltest -rpath ${.CURDIR}/../libtest
XNOMAN=         yes
X
X.include <bsd.prog.mk>
END-of-./runtest/Makefile
echo x - ./runtest/runtest.cpp
sed 's/^X//' >./runtest/runtest.cpp << 'END-of-./runtest/runtest.cpp'
X#include <stdio.h>
X#include <libtest.h>
X
Xvoid test_proc(const char *param) {
X  try {
X    hello(param);
X  } 
X  catch(const char* exc) {
X    printf("Catched exception: %s\n", exc);
X  }
X  catch(...) {
X    printf("Catched unknown exception\n");
X  }
X}
X
Xint main() {
X  test_proc("Test");
X  return 0;
X}
END-of-./runtest/runtest.cpp
echo x - ./Makefile
sed 's/^X//' >./Makefile << 'END-of-./Makefile'
XSUBDIR=libtest runtest
X
X.include <bsd.subdir.mk>
END-of-./Makefile
echo c - ./libtest
mkdir -p ./libtest > /dev/null 2>&1
echo x - ./libtest/Makefile
sed 's/^X//' >./libtest/Makefile << 'END-of-./libtest/Makefile'
X# $FreeBSD: src/lib/libalias/Makefile,v 1.12 1999/08/27 23:58:00 peter Exp $
X
XLIB=           test
XSHLIB_MAJOR=   1
XSHLIB_MINOR=   0
XSRCS=          libtest.cpp
XCC=             c++
XCFLAGS=         -g
X#CXXFLAGS+=      -pthread
X#LDFLAGS+=       -pthread
XNOMAN=         yes
X
X.include <bsd.lib.mk>
END-of-./libtest/Makefile
echo x - ./libtest/libtest.cpp
sed 's/^X//' >./libtest/libtest.cpp << 'END-of-./libtest/libtest.cpp'
X
Xvoid Foo() {
X  throw "String Exception";
X}
X
Xvoid hello(const char* msg) {
X  try {
X    Foo();
X  }
X  catch(const char* msg) {
X    throw;
X  }
X}
END-of-./libtest/libtest.cpp
echo x - ./libtest/libtest.h
sed 's/^X//' >./libtest/libtest.h << 'END-of-./libtest/libtest.h'
X#ifndef _LIBTEST_H_
X#define _LIBTEST_H_
X
Xvoid hello(const char*);
X
X#endif
END-of-./libtest/libtest.h
exit



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]