This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: [Bug libgcj/13212] JNI/CNI AttachCurrentThread does not register thread with garbage collector
- From: Richard Guenther <rguenther at suse dot de>
- To: java at gcc dot gnu dot org
- Date: Sat, 25 Mar 2006 00:23:25 +0100 (CET)
- Subject: Re: [Bug libgcj/13212] JNI/CNI AttachCurrentThread does not register thread with garbage collector
- References: <bug-13212-7355@http.gcc.gnu.org/bugzilla/> <20060324174125.7739.qmail@sourceware.org>
On Fri, 24 Mar 2006, aph at gcc dot gnu dot org wrote:
> ------- Comment #28 from aph at gcc dot gnu dot org 2006-03-24 17:41 -------
> Richard Guenther: should this be posted to java@gcc.gnu.org for discussion?
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13212
Hmm, I guess so. Me and Michael Matz have tried to somehow work around
the gjc GC issues with OpenOffice which does open libgcj via dlopen and
such suffers from the thread registration problem. On the 4.1 branch
there is the workaround to have libgcj provide pthread_create which should
in theory override libpthread.so pthread_create. This works only if
you link against libgcj, not if you later dlopen it, because you then
bound to say pthread_create@GLIBC_2.1. To work around this issue we made
libgcj provide pthread_create with the same symver as glibc does. This
exposes another issue, namely boehm GC being configured with
GC_all_interior_pointers set to 1 by default - which causes GC_bl_init
to not initialize GC_old_normal_bl and others. libgcj unfortunately
sets GC_all_interior_pointers to 0 at init time, which then causes the
uninitialized GC_old_normal_bl to be used and we segfault. To work around
this we changed boehm to default to GC_all_interior_pointers 0 instead.
Now, while this seems to solve the OpenOffice problems if you LD_PRELOAD
libgcj, the change seems to cause libjava testsuite failures (which we
didn't yet investigate):
FAIL: PR18699 execution - bytecode->native test
FAIL: PR18699 execution - gij test
FAIL: PR18699 execution - source compiled test
FAIL: PR18699 -O3 execution - bytecode->native test
FAIL: PR18699 -O3 execution - source compiled test
FAIL: Process_1 execution - bytecode->native test
FAIL: Process_1 execution - gij test
FAIL: Process_1 execution - source compiled test
FAIL: Process_1 -O3 execution - bytecode->native test
FAIL: Process_1 -O3 execution - source compiled test
FAIL: Process_2 execution - bytecode->native test
FAIL: Process_2 execution - gij test
FAIL: Process_2 execution - source compiled test
FAIL: Process_2 -O3 execution - bytecode->native test
FAIL: Process_2 -O3 execution - source compiled test
FAIL: Process_3 execution - bytecode->native test
FAIL: Process_3 execution - gij test
FAIL: Process_3 execution - source compiled test
FAIL: Process_3 -O3 execution - bytecode->native test
FAIL: Process_3 -O3 execution - source compiled test
FAIL: Process_4 execution - bytecode->native test
FAIL: Process_4 execution - gij test
FAIL: Process_4 execution - source compiled test
FAIL: Process_4 -O3 execution - bytecode->native test
FAIL: Process_4 -O3 execution - source compiled test
FAIL: Process_5 execution - bytecode->native test
FAIL: Process_5 execution - gij test
FAIL: Process_5 execution - source compiled test
FAIL: Process_5 -O3 execution - bytecode->native test
FAIL: Process_5 -O3 execution - source compiled test
FAIL: Process_6 execution - bytecode->native test
FAIL: Process_6 execution - gij test
FAIL: Process_6 execution - source compiled test
FAIL: Process_6 -O3 execution - bytecode->native test
FAIL: Process_6 -O3 execution - source compiled test
FAIL: SyncTest execution - bytecode->native test
FAIL: SyncTest execution - gij test
FAIL: SyncTest execution - source compiled test
FAIL: SyncTest -O3 execution - bytecode->native test
FAIL: Thread_Alive execution - bytecode->native test
FAIL: Thread_Alive execution - gij test
FAIL: Thread_Alive execution - source compiled test
FAIL: Thread_Alive -O3 execution - bytecode->native test
FAIL: Thread_Alive -O3 execution - source compiled test
FAIL: Thread_Interrupt execution - bytecode->native test
FAIL: Thread_Interrupt execution - gij test
FAIL: Thread_Interrupt execution - source compiled test
FAIL: Thread_Interrupt -O3 execution - bytecode->native test
FAIL: Thread_Interrupt -O3 execution - source compiled test
FAIL: Thread_Join execution - gij test
FAIL: Thread_Monitor execution - gij test
FAIL: Thread_Wait_2 execution - bytecode->native test
FAIL: Thread_Wait_2 execution - gij test
FAIL: Thread_Wait_2 execution - source compiled test
FAIL: Thread_Wait_2 -O3 execution - bytecode->native test
FAIL: Thread_Wait_2 -O3 execution - source compiled test
FAIL: Thread_Wait execution - bytecode->native test
FAIL: Thread_Wait execution - gij test
FAIL: Thread_Wait execution - source compiled test
FAIL: Thread_Wait_Interrupt execution - bytecode->native test
FAIL: Thread_Wait_Interrupt execution - gij test
FAIL: Thread_Wait_Interrupt execution - source compiled test
FAIL: Thread_Wait_Interrupt -O3 execution - bytecode->native test
FAIL: Thread_Wait_Interrupt -O3 execution - source compiled test
FAIL: Thread_Wait -O3 execution - bytecode->native test
FAIL: Thread_Wait -O3 execution - source compiled test
FAIL: TLtest execution - bytecode->native test
FAIL: TLtest execution - gij test
FAIL: TLtest execution - source compiled test
FAIL: TLtest -O3 execution - bytecode->native test
FAIL: TLtest -O3 execution - source compiled test
FAIL:
/usr/src/packages/BUILD/gcc-4.1.0/obj-x86_64-suse-linux/x86_64-suse-linux/libjava/testsuite/TestEarlyGC.exe
execution -
/usr/src/packages/BUILD/gcc-4.1.0/obj-x86_64-suse-linux/x86_64-suse-linux/libjava/testsuite/TestEarlyGC.exe
FAIL:
/usr/src/packages/BUILD/gcc-4.1.0/obj-x86_64-suse-linux/x86_64-suse-linux/libjava/testsuite/TestLeak.exe
execution -
/usr/src/packages/BUILD/gcc-4.1.0/obj-x86_64-suse-linux/x86_64-suse-linux/libjava/testsuite/TestLeak.exe
The patch we used is appended below. Any suggestions on the
GC_all_interior_pointers problems or on the general issue of late
initializing libgcj via dlopen?
Thanks,
Richard.
Index: boehm-gc/Makefile.in
===================================================================
*** boehm-gc/Makefile.in (revision 112314)
--- boehm-gc/Makefile.in (working copy)
*************** libgcjgc_convenience_la_SOURCES = $(GC_S
*** 275,281 ****
# linuxthread semaphore functions get linked:
libgcjgc_la_LIBADD = @addobjs@ $(THREADLIBS)
libgcjgc_la_DEPENDENCIES = @addobjs@
! libgcjgc_la_LDFLAGS = -version-info 1:1:0 -rpath $(toolexeclibdir)
libgcjgc_convenience_la_LIBADD = @addobjs@
libgcjgc_convenience_la_DEPENDENCIES = @addobjs@
AM_CXXFLAGS = @GC_CFLAGS@
--- 275,281 ----
# linuxthread semaphore functions get linked:
libgcjgc_la_LIBADD = @addobjs@ $(THREADLIBS)
libgcjgc_la_DEPENDENCIES = @addobjs@
! libgcjgc_la_LDFLAGS = -version-info 1:1:0 -Wl,--version-script=libgcjgc.map -rpath $(toolexeclibdir)
libgcjgc_convenience_la_LIBADD = @addobjs@
libgcjgc_convenience_la_DEPENDENCIES = @addobjs@
AM_CXXFLAGS = @GC_CFLAGS@
Index: boehm-gc/configure.ac
===================================================================
*** boehm-gc/configure.ac (revision 112314)
--- boehm-gc/configure.ac (working copy)
*************** dnl Include defines that have become de
*** 410,416 ****
dnl ALL_INTERIOR_POINTERS can be overridden in startup code.
AC_DEFINE(SILENT,1,[disables statistics printing])
AC_DEFINE(NO_SIGNALS,1,[does not disable signals])
! AC_DEFINE(ALL_INTERIOR_POINTERS,1,[allows all pointers to the interior of objects to be recognized])
dnl By default, make the library as general as possible.
AC_DEFINE(JAVA_FINALIZATION,1,[make it somewhat safer to finalize objects out of order])
--- 410,416 ----
dnl ALL_INTERIOR_POINTERS can be overridden in startup code.
AC_DEFINE(SILENT,1,[disables statistics printing])
AC_DEFINE(NO_SIGNALS,1,[does not disable signals])
! AC_DEFINE(ALL_INTERIOR_POINTERS,0,[allows all pointers to the interior of objects to be recognized])
dnl By default, make the library as general as possible.
AC_DEFINE(JAVA_FINALIZATION,1,[make it somewhat safer to finalize objects out of order])
*************** EOF
*** 466,471 ****
--- 466,473 ----
esac
if test -n "$symver"; then
AC_DEFINE_UNQUOTED(GC_PTHREAD_SYM_VERSION, "$symver", [symbol version of pthread_create])
+ GC_PTHREAD_SYM_VERSION_MAP="$symver"
+ AC_SUBST(GC_PTHREAD_SYM_VERSION_MAP)
fi
*************** fi
*** 493,497 ****
AC_CONFIG_HEADERS([include/gc_config.h include/gc_ext_config.h])
! AC_CONFIG_FILES(Makefile include/Makefile)
AC_OUTPUT
--- 495,499 ----
AC_CONFIG_HEADERS([include/gc_config.h include/gc_ext_config.h])
! AC_CONFIG_FILES(Makefile include/Makefile libgcjgc.map)
AC_OUTPUT
Index: boehm-gc/configure
===================================================================
*** boehm-gc/configure (revision 112314)
--- boehm-gc/configure (working copy)
*************** ac_includes_default="\
*** 309,315 ****
# include <unistd.h>
#endif"
! ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS multi_basedir build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os target_noncanonical mkinstalldirs INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CXX ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CFLAGS CXXFLAGS CCAS CCASFLAGS AS ac_ct_AS AR ac_ct_AR RANLIB ac_ct_RANLIB MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT GC_CFLAGS LN_S LIBTOOL CXXCPP CPPFLAGS THREADLIBS POWERPC_DARWIN_TRUE POWERPC_DARWIN_FALSE EXTRA_TEST_LIBS target_all CPLUSPLUS_TRUE CPLUSPLUS_FALSE AM_CPPFLAGS addobjs addincludes addlibs addtests CPP EGREP MY_CFLAGS toolexecdir toolexeclibdir LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
--- 309,315 ----
# include <unistd.h>
#endif"
! ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS multi_basedir build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os target_noncanonical mkinstalldirs INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CXX ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CFLAGS CXXFLAGS CCAS CCASFLAGS AS ac_ct_AS AR ac_ct_AR RANLIB ac_ct_RANLIB MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT GC_CFLAGS LN_S LIBTOOL CXXCPP CPPFLAGS THREADLIBS POWERPC_DARWIN_TRUE POWERPC_DARWIN_FALSE EXTRA_TEST_LIBS target_all CPLUSPLUS_TRUE CPLUSPLUS_FALSE AM_CPPFLAGS addobjs addincludes addlibs addtests CPP EGREP MY_CFLAGS GC_PTHREAD_SYM_VERSION_MAP toolexecdir toolexeclibdir LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
*************** _ACEOF
*** 6539,6545 ****
cat >>confdefs.h <<\_ACEOF
! #define ALL_INTERIOR_POINTERS 1
_ACEOF
--- 6539,6545 ----
cat >>confdefs.h <<\_ACEOF
! #define ALL_INTERIOR_POINTERS 0
_ACEOF
*************** cat >>confdefs.h <<_ACEOF
*** 6647,6652 ****
--- 6647,6654 ----
#define GC_PTHREAD_SYM_VERSION "$symver"
_ACEOF
+ GC_PTHREAD_SYM_VERSION_MAP="$symver"
+
fi
*************** fi
*** 6675,6681 ****
ac_config_headers="$ac_config_headers include/gc_config.h include/gc_ext_config.h"
! ac_config_files="$ac_config_files Makefile include/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
--- 6677,6683 ----
ac_config_headers="$ac_config_headers include/gc_config.h include/gc_ext_config.h"
! ac_config_files="$ac_config_files Makefile include/Makefile libgcjgc.map"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
*************** do
*** 7267,7272 ****
--- 7269,7275 ----
# Handling of arguments.
"Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"include/Makefile" ) CONFIG_FILES="$CONFIG_FILES include/Makefile" ;;
+ "libgcjgc.map" ) CONFIG_FILES="$CONFIG_FILES libgcjgc.map" ;;
"default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;;
"depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
"include/gc_config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS include/gc_config.h" ;;
*************** s,@addtests@,$addtests,;t t
*** 7444,7449 ****
--- 7447,7453 ----
s,@CPP@,$CPP,;t t
s,@EGREP@,$EGREP,;t t
s,@MY_CFLAGS@,$MY_CFLAGS,;t t
+ s,@GC_PTHREAD_SYM_VERSION_MAP@,$GC_PTHREAD_SYM_VERSION_MAP,;t t
s,@toolexecdir@,$toolexecdir,;t t
s,@toolexeclibdir@,$toolexeclibdir,;t t
s,@LIBOBJS@,$LIBOBJS,;t t
Index: boehm-gc/libgcjgc.map.in
===================================================================
*** boehm-gc/libgcjgc.map.in (revision 0)
--- boehm-gc/libgcjgc.map.in (revision 0)
***************
*** 0 ****
--- 1,2 ----
+ @GC_PTHREAD_SYM_VERSION_MAP@ {
+ };
Index: boehm-gc/pthread_support.c
===================================================================
*** boehm-gc/pthread_support.c (revision 112314)
--- boehm-gc/pthread_support.c (working copy)
*************** constr (void)
*** 1231,1237 ****
int
! GC_PTHREAD_CREATE_NAME(pthread_t *new_thread,
const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg)
{
--- 1231,1237 ----
int
! GC_pthread_create (pthread_t *new_thread,
const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg)
{
*************** GC_PTHREAD_CREATE_NAME(pthread_t *new_th
*** 1308,1313 ****
--- 1308,1315 ----
return(result);
}
+ __asm__ (".symver pthread_create, pthread_create@@" GC_PTHREAD_SYM_VERSION);
+
#ifdef GENERIC_COMPARE_AND_SWAP
pthread_mutex_t GC_compare_and_swap_lock = PTHREAD_MUTEX_INITIALIZER;
Index: boehm-gc/Makefile.am
===================================================================
*** boehm-gc/Makefile.am (revision 112314)
--- boehm-gc/Makefile.am (working copy)
*************** libgcjgc_convenience_la_SOURCES = $(GC_S
*** 38,44 ****
# linuxthread semaphore functions get linked:
libgcjgc_la_LIBADD = @addobjs@ $(THREADLIBS)
libgcjgc_la_DEPENDENCIES = @addobjs@
! libgcjgc_la_LDFLAGS = -version-info 1:1:0 -rpath $(toolexeclibdir)
libgcjgc_convenience_la_LIBADD = @addobjs@
libgcjgc_convenience_la_DEPENDENCIES = @addobjs@
--- 38,44 ----
# linuxthread semaphore functions get linked:
libgcjgc_la_LIBADD = @addobjs@ $(THREADLIBS)
libgcjgc_la_DEPENDENCIES = @addobjs@
! libgcjgc_la_LDFLAGS = -version-info 1:1:0 -Wl,--version-script=libgcjgc.map -rpath $(toolexeclibdir)
libgcjgc_convenience_la_LIBADD = @addobjs@
libgcjgc_convenience_la_DEPENDENCIES = @addobjs@
Index: libjava/Makefile.in
===================================================================
*** libjava/Makefile.in (revision 112314)
--- libjava/Makefile.in (working copy)
*************** xlib_nat_files = $(xlib_nat_source_files
*** 728,734 ****
# certain linuxthread functions get linked:
libgcj_la_LDFLAGS = -rpath $(toolexeclibdir) $(THREADLDFLAGS) $(THREADLIBS) \
$(LIBLTDL) $(SYS_ZLIBS) \
! -version-info `grep -v '^\#' $(srcdir)/libtool-version`
libgcj_la_LIBADD = \
classpath/native/fdlibm/libfdlibm.la \
--- 728,734 ----
# certain linuxthread functions get linked:
libgcj_la_LDFLAGS = -rpath $(toolexeclibdir) $(THREADLDFLAGS) $(THREADLIBS) \
$(LIBLTDL) $(SYS_ZLIBS) \
! -version-info `grep -v '^\#' $(srcdir)/libtool-version` -Wl,--version-script=../boehm-gc/libgcjgc.map
libgcj_la_LIBADD = \
classpath/native/fdlibm/libfdlibm.la \
Index: libjava/Makefile.am
===================================================================
*** libjava/Makefile.am (revision 112314)
--- libjava/Makefile.am (working copy)
*************** xlib_nat_files = $(xlib_nat_source_files
*** 225,231 ****
## The mysterious backslash in the grep pattern is consumed by make.
libgcj_la_LDFLAGS = -rpath $(toolexeclibdir) $(THREADLDFLAGS) $(THREADLIBS) \
$(LIBLTDL) $(SYS_ZLIBS) \
! -version-info `grep -v '^\#' $(srcdir)/libtool-version`
libgcj_la_LIBADD = \
classpath/native/fdlibm/libfdlibm.la \
$(all_packages_source_files:.list=.lo) \
--- 225,231 ----
## The mysterious backslash in the grep pattern is consumed by make.
libgcj_la_LDFLAGS = -rpath $(toolexeclibdir) $(THREADLDFLAGS) $(THREADLIBS) \
$(LIBLTDL) $(SYS_ZLIBS) \
! -version-info `grep -v '^\#' $(srcdir)/libtool-version` -Wl,--version-script=../boehm-gc/libgcjgc.map
libgcj_la_LIBADD = \
classpath/native/fdlibm/libfdlibm.la \
$(all_packages_source_files:.list=.lo) \