[fedora-java] Thread registration work-around?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



FC5t1's Eclipse crashes on start-up on x86-64 systems...  

https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=174612

..due to this bug..

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13212

I don't believe this problem is unique to x86-64 - it's just highly
reproducible on that platform.

This is the same thing that was preventing RSSOwl from running on any
platform.

If we aren't prepared to import a new GC snapshot, or backport Hans'
fix, then I propose we modify java-gcj-compat's java.c wrapper to
LD_PRELOAD the following .so before every gij run.   It makes sure that
any stray pthread_create() calls go through the GC's thread registration
process.  Comments?


/* pthread_create registration wrapper for libgcj.  Build it like
   so...
   gcc -shared -o pr13212.so pr13212.c -lgcj  
*/

#define _GNU_SOURCE
#include <dlfcn.h>
#include <stdlib.h>
#include <pthread.h>

// A pointer to the real pthread_create_

static int (*pthread_create_) (pthread_t *__restrict __newthread,
			       __const pthread_attr_t *__restrict __attr,
			       void *(*__start_routine) (void *),
			       void *__restrict __arg);


// The Boehm collector's pthread_create wrapper.
extern int GC_pthread_create (pthread_t *__restrict __newthread,
			      __const pthread_attr_t *__restrict __attr,
			      void *(*__start_routine) (void *),
			      void *__restrict __arg);

// The start routine used by the Boehm collector.  We'll use this to 
// recognize pthread_create calls made by the collector's wrapper.
extern void *GC_start_routine (void *);


/* Force constr to execute prior to main().  */
static void constr (void) __attribute__ ((constructor));

static void
constr (void)
{
  /* Get a pointer to the real pthread_create().  */
  pthread_create_ = dlsym (RTLD_NEXT, "pthread_create");

  if (pthread_create_ == NULL)
    abort ();
}

/** Wrap the pthread_create function.  */
int pthread_create (pthread_t *__restrict __newthread,
		    __const pthread_attr_t *__restrict __attr,
		    void *(*__start_routine) (void *),
		    void *__restrict __arg)
{
  // Call the real pthread_create() if we're called from boehm's wrapper,
  // and call boehm's wrapper otherwise.
  if (__start_routine == GC_start_routine)
    return pthread_create_ (__newthread, __attr, __start_routine, __arg);
  else
    return GC_pthread_create (__newthread, __attr, __start_routine, __arg);
}



[Index of Archives]     [Red Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux