Bug 20699 - gij -ms segfaults
Summary: gij -ms segfaults
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: libgcj (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: ---
Assignee: Hans Boehm
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-31 02:01 UTC by Thomas Fitzsimmons
Modified: 2016-09-30 22:54 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-05-25 18:35:42


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Fitzsimmons 2005-03-31 02:01:18 UTC
Passing the -ms option with any size argument to gij causes a segfault in the
garbage collector:

$ gdb --args gij -ms 56M Hello
GNU gdb Red Hat Linux (6.3.0.0-0.29rh)
Copyright 2004 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-gnu"...(no debugging symbols found)
Using host libthread_db library "/lib/tls/libthread_db.so.1".

(gdb) r
Starting program: /home/fitzsim/install/bin/gij -ms 56M Hello
[Thread debugging using libthread_db enabled]
[New Thread -1208486208 (LWP 12119)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208486208 (LWP 12119)]
0x01729265 in GC_is_black_listed (h=0x11000, len=12288) at
/home/fitzsim/sources/gcc/boehm-gc/blacklst.c:242
242           if (get_pht_entry_from_index(GC_old_normal_bl, index)
(gdb) bt
#0  0x01729265 in GC_is_black_listed (h=0x11000, len=12288) at
/home/fitzsim/sources/gcc/boehm-gc/blacklst.c:242
#1  0x01726c6d in GC_allochblk_nth (sz=2054, kind=1, flags=0 '\0', n=16) at
/home/fitzsim/sources/gcc/boehm-gc/allchblk.c:645
#2  0x01726a2a in GC_allochblk (sz=2054, kind=1, flags=0) at
/home/fitzsim/sources/gcc/boehm-gc/allchblk.c:561
#3  0x0172da47 in GC_alloc_large (lw=2054, k=1, flags=0) at
/home/fitzsim/sources/gcc/boehm-gc/malloc.c:53
#4  0x0172db40 in GC_alloc_large_and_clear (lw=2054, k=1, flags=0) at
/home/fitzsim/sources/gcc/boehm-gc/malloc.c:86
#5  0x0172dd01 in GC_generic_malloc_inner (lb=8216, k=1) at
/home/fitzsim/sources/gcc/boehm-gc/malloc.c:154
#6  0x01736e26 in GC_key_create (key_ptr=0x1ce6da0, destructor=0) at
/home/fitzsim/sources/gcc/boehm-gc/specific.c:27
#7  0x0173859b in GC_init_thread_local (p=0x1cda460) at
/home/fitzsim/sources/gcc/boehm-gc/pthread_support.c:224
#8  0x0173917e in GC_init_parallel () at
/home/fitzsim/sources/gcc/boehm-gc/pthread_support.c:954
#9  0x017329ef in GC_init () at /home/fitzsim/sources/gcc/boehm-gc/misc.c:503
#10 0x0172c7df in GC_init_gcj_malloc (mp_index=0, mp=0x15a836c) at
/home/fitzsim/sources/gcc/boehm-gc/gcj_mlc.c:60
#11 0x015a9c82 in _Jv_InitGC () at /home/fitzsim/sources/gcc/libjava/boehm.cc:627
#12 0x011648b7 in _Jv_CreateJavaVM (vm_args=0x0) at
/home/fitzsim/sources/gcc/libjava/prims.cc:1092
#13 0x01164c89 in _Jv_RunMain (klass=0x0, name=0xbff97842 "Hello", argc=1,
argv=0xbfee3cb0, is_jar=false) at /home/fitzsim/sources/gcc/libjava/prims.cc:1186
#14 0x00b83045 in main (argc=4, argv=0xbfee3ca4) at
/home/fitzsim/sources/gcc/libjava/gij.cc:169
#15 0x0085cdb6 in __libc_start_main () from /lib/tls/libc.so.6
#16 0x08048461 in _start ()
(gdb)
Comment 1 Hans Boehm 2005-04-08 00:18:15 UTC
The problem here is that _Jv_InitGC is called to late, and hence 
GC_all_interior_pointers is cleared after the GC has been run.  This is 
documented not to work in gc.h.

In particular _Jv_GCSetInitialHeapSize (which turns into GC_expand_hp) is 
called earlier.

If things are always done in this order, it may make sense to have 
_Jv_GCSetInitialHeapSize  just set a variable, and have _Jv_InitGC do the 
expansion.

I'll be travelling next week, and thus won't get a chance to generate a patch 
soon.
Comment 2 Thomas Fitzsimmons 2005-05-25 18:34:24 UTC
Hans, are you still planning on creating a patch for this?
Comment 3 Andrew Pinski 2016-09-30 22:54:08 UTC
Closing as won't fix as libgcj (and the java front-end) has been removed from the trunk.