[Gc] RE: Further investigation of Solaris 10/x86 gctest failure

Rainer Orth ro at TechFak.Uni-Bielefeld.DE
Thu Jun 9 10:35:46 PDT 2005


Hans,

> My general approach would be:
> 
> - Forget about the incremental GC failure for now.  Change gcconfig.h
> so that it doesn't get enabled for Solaris/X86.  I think there are

This worked (as expected).  However, if I switch to the pthreads code as
you suggest below, I can re-enable it without problems.

> few clients anyway.  If you want to try to track this down, try
> -DCHECKSUMS, but that's likely to require some fiddling.  (This option
> gets tested every two or three years, when some "virtual dirty bit"
> implementation breaks.)

I gave this a quick try, but couldn't make immediate sense of the errors
detected.  But this is probably moot given that the alternative approach
works.

> - As far as the threads failure is concerned, it may be that the
> best approach is to discard the Solaris specific code, and switch
> to the generic pthreads code.  (Presumably you don't care about the
> old Solaris threads interface.)  This is my plan for 7.0 anyway.

Indeed, I don't.

> (This is the approach that 6.5 successfully used for AIX and Irix.)

That's what I did as a quick hack, and it worked amazingly well.  I'm
including it below, but it is certainly not ready for inclusion as is.

Here's what I did:

* I tried to make sure that GC_SOLARIS_THREADS isn't defined any longer, so
  we assume only pthreads support.  I needed to hack dyn_load.c to avoid
  running into the !SRC_M3 error.

* solaris_pthreads.c and solaris_threads.c are #if 0-ed at the moment; they
  should be removed completely for a proper patch.

* Now we need to link with -lrt as well, which defines sched_yield and the
  sem_* function.  This is currently done unconditionally, but needs to be
  improved to use -lposix4 up to Solaris 2.6 and -lrt only beyond.
  Cf. GCC's libjava/configure.ac for an example.

* gcconfig.h now contains an Solaris 10/amd64 clause, which certainly needs
  cleanups, but also worked as is.  One issue that took some debugging
  initially was the need to define ELF_CLASS to ELFCLASS64 (as done for
  Solaris/SPARC V9) so dyn_load.c picks up the proper ELF types.

* pthread_support.c (GC_thr_init) can use sysconf(_SC_NPROCESSORS_ONLN) on
  Solaris 2, too.

With those changes, gctest passes on Solaris 10/x86 and amd64, both with cc
and gcc, with and without pthreads.  I'm pretty sure there's need for
additional testing (certainly on SPARC in addition to x86), but just wanted
to give a heads-up.

With this change, libjava tests on Solaris 10/amd64 look resonable (and on
par with the x86 results, with one exception: all the gij tests fail).  I'm
not sure how to proceed for GCC integration, though: for GCC mainline, such
a switch from solaris threads to pthreads (perhaps by import of gc 6.6 if
that appears and integrates a cleaned-up version of those changes) is
clearly the way to go, but I'm unsure about the 4.0 branch.  Maybe such a
change is too intrusive; I'll have to check this once a final patch is
ready.

	Rainer

-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University


===================================================================
RCS file: RCS/configure,v
retrieving revision 1.1
diff -up -r1.1 configure
--- configure	2005/05/16 23:28:32	1.1
+++ configure	2005/06/07 00:44:46
@@ -4043,13 +4043,10 @@ _ACEOF
       	;;
      *-*-solaris*)
 	cat >>confdefs.h <<\_ACEOF
-#define GC_SOLARIS_THREADS 1
-_ACEOF
-
-	cat >>confdefs.h <<\_ACEOF
 #define GC_SOLARIS_PTHREADS 1
 _ACEOF
 
+	THREADDLLIBS="-lpthread -lrt"
 	;;
      *-*-irix*)
 	cat >>confdefs.h <<\_ACEOF
===================================================================
RCS file: RCS/configure.in,v
retrieving revision 1.1
diff -up -r1.1 configure.in
--- configure.in	2005/02/09 19:35:23	1.1
+++ configure.in	2005/06/07 00:44:46
@@ -111,8 +111,8 @@ case "$THREADS" in
 	THREADDLLIBS=-pthread
       	;;
      *-*-solaris*)
-	AC_DEFINE(GC_SOLARIS_THREADS)
 	AC_DEFINE(GC_SOLARIS_PTHREADS)
+	THREADDLLIBS="-lpthread -lrt"
 	;;
      *-*-irix*)
 	AC_DEFINE(GC_IRIX_THREADS)
===================================================================
RCS file: RCS/dyn_load.c,v
retrieving revision 1.1
diff -up -r1.1 dyn_load.c
--- dyn_load.c	2005/05/17 00:47:30	1.1
+++ dyn_load.c	2005/06/07 00:12:50
@@ -214,7 +214,7 @@ static ptr_t GC_first_common()
 
 # if defined(SUNOS4) || defined(SUNOS5DL)
 /* Add dynamic library data sections to the root set.		*/
-# if !defined(PCR) && !defined(GC_SOLARIS_THREADS) && defined(THREADS)
+# if !defined(PCR) && !defined(GC_SOLARIS_PTHREADS) && defined(THREADS)
 #   ifndef SRC_M3
 	--> fix mutual exclusion with dlopen
 #   endif  /* We assume M3 programs don't call dlopen for now */
===================================================================
RCS file: include/RCS/gc_config_macros.h,v
retrieving revision 1.1
diff -up -r1.1 include/gc_config_macros.h
--- include/gc_config_macros.h	2005/04/22 00:57:34	1.1
+++ include/gc_config_macros.h	2005/06/07 00:01:42
@@ -108,7 +108,7 @@
 # define GC_WIN32_THREADS
 #endif
 
-#if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
+#if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS) && 0
 #   define GC_SOLARIS_THREADS
 #endif
 
===================================================================
RCS file: include/private/RCS/gcconfig.h,v
retrieving revision 1.1
diff -up -r1.1 include/private/gcconfig.h
--- include/private/gcconfig.h	2005/05/20 20:48:29	1.1
+++ include/private/gcconfig.h	2005/06/07 00:24:44
@@ -153,6 +153,11 @@
 #    define SUNOS5
 #    define mach_type_known
 # endif
+# if defined(sun) && defined(__amd64)
+#    define X86_64
+#    define SUNOS5
+#    define mach_type_known
+# endif
 # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
 #    define I386
 #    define OS2
@@ -1037,9 +1042,12 @@
 #       include <sys/vm.h>
 #	define STACKBOTTOM USRSTACK
 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
-/* It appears to be fixed in 2.8 and 2.9.				*/
+/* It appears to be fixed in 2.8 and 2.9, but breaks again in 2.10 with */
+/* the introduction of amd64 support.					*/
 #	ifdef SOLARIS25_PROC_VDB_BUG_FIXED
+/*#	 if 0*/
 #	  define PROC_VDB
+/*#	 endif*/
 #	endif
 #	define DYNAMIC_LOADING
 #	if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
@@ -1936,6 +1944,39 @@
 	extern char etext[];
 #	define SEARCH_FOR_DATA_START
 #   endif
+#   ifdef SUNOS5
+#	define ELF_CLASS ELFCLASS64
+#	define OS_TYPE "SUNOS5"
+        extern int _etext[], _end[];
+  	extern ptr_t GC_SysVGetDataStart();
+#       define DATASTART GC_SysVGetDataStart(0x1000, _etext)
+#	define DATAEND (_end)
+/*	# define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7,  	*/
+/*      but reportedly breaks under 2.8.  It appears that the stack	*/
+/* 	base is a property of the executable, so this should not break	*/
+/* 	old executables.						*/
+/*  	HEURISTIC2 probably works, but this appears to be preferable.	*/
+/* #       include <sys/vm.h> */
+/* #	define STACKBOTTOM USRSTACK */
+#	define HEURISTIC2
+/*	This is broken in 2.10.						*/
+/*#	if 0*/
+#	define PROC_VDB
+/*#	endif*/
+#	define DYNAMIC_LOADING
+#	if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
+#	    define USE_MMAP
+	    /* Otherwise we now use calloc.  Mmap may result in the	*/
+	    /* heap interleaved with thread stacks, which can result in	*/
+	    /* excessive blacklisting.  Sbrk is unusable since it	*/
+	    /* doesn't interact correctly with the system malloc.	*/
+#	endif
+#       ifdef USE_MMAP
+#         define HEAP_START (ptr_t)0x40000000
+#       else
+#	  define HEAP_START DATAEND
+#       endif
+#   endif
 # endif
 
 #if defined(LINUX) && defined(USE_MMAP)
@@ -2082,7 +2123,7 @@
 # endif /* CLEAR_DOUBLE */
 
 	/* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
-# if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
+# if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS) && 0
 #   define GC_SOLARIS_THREADS
 # endif
 
===================================================================
RCS file: RCS/pthread_support.c,v
retrieving revision 1.1
diff -up -r1.1 pthread_support.c
--- pthread_support.c	2005/05/21 00:02:07	1.1
+++ pthread_support.c	2005/06/07 00:23:05
@@ -873,7 +873,8 @@ void GC_thr_init()
 #       if defined(GC_HPUX_THREADS)
 	  GC_nprocs = pthread_num_processors_np();
 #       endif
-#	if defined(GC_OSF1_THREADS) || defined(GC_AIX_THREADS)
+#	if defined(GC_OSF1_THREADS) || defined(GC_AIX_THREADS) || \
+	   defined(GC_SOLARIS_PTHREADS)
 	  GC_nprocs = sysconf(_SC_NPROCESSORS_ONLN);
 	  if (GC_nprocs <= 0) GC_nprocs = 1;
 #	endif
===================================================================
RCS file: RCS/solaris_pthreads.c,v
retrieving revision 1.1
diff -up -r1.1 solaris_pthreads.c
--- solaris_pthreads.c	2004/08/15 01:32:25	1.1
+++ solaris_pthreads.c	2005/06/06 23:57:27
@@ -18,7 +18,7 @@
 
 # include "private/gc_priv.h"
 
-# if defined(GC_SOLARIS_PTHREADS)
+# if defined(GC_SOLARIS_PTHREADS) && 0
 # include <pthread.h>
 # include <thread.h>
 # include <signal.h>
===================================================================
RCS file: RCS/solaris_threads.c,v
retrieving revision 1.1
diff -up -r1.1 solaris_threads.c
--- solaris_threads.c	2005/03/22 23:27:32	1.1
+++ solaris_threads.c	2005/06/06 23:57:46
@@ -18,7 +18,7 @@
 
 # include "private/gc_priv.h"
 
-# if defined(GC_SOLARIS_THREADS) || defined(GC_SOLARIS_PTHREADS)
+# if (defined(GC_SOLARIS_THREADS) || defined(GC_SOLARIS_PTHREADS)) && 0
 # include "private/solaris_threads.h"
 # include <thread.h>
 # include <synch.h>


More information about the Gc mailing list