gcj, gij; dynamic compile problem?
weppnesp@eckerd.edu
weppnesp@eckerd.edu
Tue Jun 24 01:52:00 GMT 2003
Hello all,
....followup to my previous mail in which i found that I can compile gcj-3.3
using the static switch only and still gij never works (linux ix86, 2.4.18-3,
redhat 7.3) Trace back for static and dynamic linkage. Sadly the GNU debugger
has problems with static case so nothing learned. The dynamic (shared) code
seems to crash in the unwind exception throw detailed below..
it was configured with only the "--enable-threads=posix" option
traceback with debugger gdb is strange on static (but program runs!)
---------------------------------------------------------------------------
[root@hildegard2 java]# gcj -o Hello -static -g --main=HelloWorld -save-temps
HelloWorld.java
[root@hildegard2 java]# Hello
Hello
[root@hildegard2 java]# gdb Hello
GNU gdb Red Hat Linux (5.1.90CVS-5)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
(gdb) run
Starting program: /root/java/Hello
Program received signal SIG32, Real-time event 32.
0x081405c6 in sigsuspend ()
(gdb) bt
#0 0x081405c6 in sigsuspend ()
#1 0x0812cefd in __pthread_wait_for_restart_signal ()
#2 0x0812cfd9 in pthread_create ()
#3 0x080b73b4 in GC_pthread_create (new_thread=0x0, attr=0xbfffe1e0,
start_routine=0, arg=0x0) at linux_threads.c:1424
#4 0x080b18c7 in _Jv_ThreadStart(java::lang::Thread*, _Jv_Thread_t*, void
(*)(java::lang::Thread*)) (thread=0x82c5d98, data=0x82ec5b0,
meth=0) at posix-threads.cc:424
#5 0x0807be21 in java::lang::Thread::start() (this=0x82f8ff8) at
java/lang/natThread.cc:316
#6 0x0804993e in _Jv_CreateJavaVM(void*) () at prims.cc:950
#7 0x080499c8 in _Jv_RunMain(java::lang::Class*, char const*, int, char
const**, bool) (klass=0x81d10a0, name=0xbfffe1e0 "001円", argc=1,
argv=0xbfffe374, is_jar=false) at prims.cc:973
#8 0x08049b6f in JvRunMain (klass=0x0, argc=0, argv=0x0) at prims.cc:1011
#9 0x08048234 in main (argc=1, argv=0xbfffe374) at HelloWorldmain.i:11
#10 0x081339b2 in __libc_start_main ()
-----------------------------------------------------------------
it got caught in thread purgatory, do i need to debug with a special option for
static?
Now with dynamic (shared) linkage, More Detail: (stepi--last few instructions)
-------------------------------------------------
uw_frame_state_for (context=0xbfffde90, fs=0xbfffddd0) at unwind-dw2.c:980
980 return _URC_NO_REASON;
(gdb)
981 }
(gdb)
_Unwind_RaiseException (exc=0x808cfa0) at unwind.inc:99
99 return _URC_END_OF_STACK;
(gdb)
104 return _URC_FATAL_PHASE1_ERROR;
(gdb)
107 if (fs.personality)
(gdb)
109 code = (*fs.personality) (1, _UA_SEARCH_PHASE, exc->exception_class,
(gdb)
Program received signal SIGSEGV, Segmentation fault.
0x00006000 in ?? ()
(gdb)
Cannot find bounds of current function
(gdb)
------------------------------------------------------------
Last bit of code debugger shows with interesting comments, last line is ****
below. So jeff, you were right, the unwind handler is the culprit somewhere in
the unwind handler. Notice also that it spells out GNUCJAVA to indicate levels
of unwinding. i had unwound CUNG when it crashed...
--------------------------------------------------------------
// Functions for Exception Support for Java.
/* Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
#include <config.h>
#include <stddef.h>
#include <stdlib.h>
#include <java/lang/Class.h>
#include <java/lang/NullPointerException.h>
#include <gcj/cni.h>
#include <jvm.h>
// unwind-pe.h uses std::abort(), but sometimes we compile libjava
// without libstdc++-v3. The following hack forces it to use
// stdlib.h's abort().
namespace std
{
static __attribute__ ((__noreturn__)) void
abort ()
{
::abort ();
}
}
#include "unwind.h"
struct alignment_test_struct
{
char space;
char end[0] __attribute__((aligned));
};
struct java_exception_header
{
/* Cache handler details between Phase 1 and Phase 2. */
_Unwind_Ptr landingPad;
int handlerSwitchValue;
/* The object being thrown. Compiled code expects this to be immediately
before the generic exception header. Which is complicated by the fact
that _Unwind_Exception is ((aligned)). */
char pad[sizeof(jthrowable) < sizeof(alignment_test_struct)
? sizeof(alignment_test_struct) - sizeof(jthrowable) : 0]
__attribute__((aligned));
jthrowable value;
/* The generic exception header. */
_Unwind_Exception unwindHeader;
};
// This is the exception class we report -- "GNUCJAVA".
const _Unwind_Exception_Class __gcj_exception_class
= ((((((((_Unwind_Exception_Class) 'G'
<< 8 | (_Unwind_Exception_Class) 'N')
<< 8 | (_Unwind_Exception_Class) 'U')
<< 8 | (_Unwind_Exception_Class) 'C')
<< 8 | (_Unwind_Exception_Class) 'J')
<< 8 | (_Unwind_Exception_Class) 'A')
<< 8 | (_Unwind_Exception_Class) 'V')
<< 8 | (_Unwind_Exception_Class) 'A');
static inline java_exception_header *
get_exception_header_from_ue (_Unwind_Exception *exc)
{
return reinterpret_cast<java_exception_header *>(exc + 1) - 1;
}
/* Perform a throw, Java style. Throw will unwind through this call,
so there better not be any handlers or exception thrown here. */
extern "C" void
_Jv_Throw (jthrowable value)
{
java_exception_header *xh
= static_cast<java_exception_header *>(_Jv_AllocRawObj (sizeof (*xh)));
if (value == NULL)
value = new java::lang::NullPointerException ();
xh->value = value;
xh->unwindHeader.exception_class = __gcj_exception_class;
xh->unwindHeader.exception_cleanup = NULL;
/* We're happy with setjmp/longjmp exceptions or region-based
exception handlers: entry points are provided here for both. */
_Unwind_Reason_Code code;
#ifdef SJLJ_EXCEPTIONS
code = _Unwind_SjLj_RaiseException (&xh->unwindHeader);
#else
code = _Unwind_RaiseException (&xh->unwindHeader); \\*****************HERE
#endif
/* If code == _URC_END_OF_STACK, then we reached top of stack without
finding a handler for the exception. Since each thread is run in
a try/catch, this oughtn't happen. If code is something else, we
encountered some sort of heinous lossage from which we could not
recover. As is the way of such things, almost certainly we will have
crashed before now, rather than actually being able to diagnose the
problem. */
abort();
}
--------------------------------------------------------------------------
Note that right before the crash a URC_END_OF_STACK was returned!
I am a computational physicist, really out of my league here, but if anybody
would like followup I would be glad to help send data (steve@netfuel.com suffers
from the same problem with same distro, os kernel, compiler).
Thanks for your help!
Steve Weppner
--------------------------------------------------------
This mail sent via Eckerd IMP: http://webmail.eckerd.edu
More information about the Java
mailing list