Hello world segfaults with -static

Boehm, Hans hans_boehm@hp.com
Wed Oct 10 09:26:00 GMT 2001


That's a new one for me.  And I don't have clue as to how that could happen.
With only a single entry in the table, GC_next_exclusion should return
either 0 or the address of the zeroth entry in GC_excl_table.  It looks to
me like next_index can be only 0 or 1.

Can you build mark_rts.c unoptimized?  If that still breaks, can you step
through GC_exclude_static_roots to see where I'm wrong?

Hans


> -----Original Message-----
> From: Martin Kahlert [ mailto:martin.kahlert@infineon.com ]
> Sent: Wednesday, October 10, 2001 6:47 AM
> To: java@gcc.gnu.org
> Subject: Hello world segfaults with -static
> 
> 
> Hi!
> 
> I do not have any idea, why this segfaults:
> 
> public class hello
> {
>  public static void main(String[] args)
>     {
>      System.out.println("Hello World");
>     }
> }
> 
> $ gcj -static -g -o hello hello.java --main=hello
> $ ./hello
> Segmentation fault
>  
> gdb's output: (although it strangly jumps around in the source)
> 
> next_index = 11163 when there is only one entry 
> (GC_excl_table_entries=1)????
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x80f3edc in GC_exclude_static_roots (start=0x81c18c0, 
> finish=0x81c1a00) at
> ../../../gcc-3.1/boehm-gc/mark_rts.c:412
> 412         GC_excl_table[next_index].e_start = (ptr_t)start;
> (gdb) where
> #0  0x80f3edc in GC_exclude_static_roots (start=0x81c18c0, 
> finish=0x81c1a00) at ../../../gcc-3.1/boehm-gc/mark_rts.c:412
> #1  0x80f46a1 in GC_init_inner () at 
> ../../../gcc-3.1/boehm-gc/misc.c:516
> #2  0x80f452b in GC_init () at ../../../gcc-3.1/boehm-gc/misc.c:442
> #3  0x80ee6bf in GC_init_gcj_malloc (mp_index=0, 
> mp=0x80916f0) at ../../../gcc-3.1/boehm-gc/gcj_mlc.c:59
> #4  0x809238a in _Z10_Jv_InitGCv () at 
> ../../../gcc-3.1/libjava/boehm.cc:491
> #5  0x805f321 in _Jv_RegisterClasses (classes=0x81cab18) at 
> ../../../gcc-3.1/libjava/java/lang/natClassLoader.cc:435
> #6  0x80481e9 in frame_dummy ()
> #7  0x80480d1 in _init ()
> #8  0x8106a99 in __libc_start_main (main=0x80481f4 <main>, argc=1,
>     ubp_av=0xbffff3b4, init=0x80480b4 <_init>, fini=0x81510e0 <_fini>,
>     rtld_fini=0, stack_end=0xbffff3ac) at 
> ../sysdeps/generic/libc-start.c:122
> 
> This is current cvs.
> Reading specs from /sw/gcc-3.1/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
> Configured with: ../gcc-3.1/configure --prefix=/sw/gcc-3.1
> --enable-languages=c++,f77,java --enable-threads=posix
> Thread model: posix
> gcc version 3.1 20011010 (experimental)
> 
> Thanks for any hint,
> Martin.
> 
> PS: It works like a charm when you omit -static.
> 
> -- 
> The early bird catches the worm. If you want something else for       
> breakfast, get up later.
> 



More information about the Java mailing list