This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GCJ 3.3 crash with string handling reproduceable case


I've put together a small program that crashes eventually. This
is not a livelock, but I created the app when I was trying
to create a usable bugreport on the livelock problem.

I compiled the classes using Eclipse, then w/GCJ.

\thisiscool-gcc\gcc-3.3\bin\gcj -o test.exe Test.class --main=Test Test$1.class

When I run it for a couple of minutes, I get a segmentation fault.



public class Test
{
 static public String replaceAll(String in, String a,  String b)
 {
  String t="";
  int i;
  for (i=0; i<(in.length()-a.length()+1); i++)
  {
   String c=in.substring(i, i+a.length());
   if (c.equals(a))
   {
    t+=b;
    i=i+a.length()-1;
   } else
   {
    t+=in.substring(i, i+1);
   }
  }
  if (i<in.length())
  {
   t+=in.substring(i, in.length()-1);
  }
  return t;
 }
 
 public static void main(String[] args)
 {
  Thread tr=new Thread(new Runnable()
  {
   public void run()
   {
    stressGB("second thread");
   }
  });
  tr.start();
  
  stressGB("first thread");
  
  
 }
 static void stressGB(String thread)
 {
  char[] abs={'a','b','c','d'};
  String foo="";
  for (int i=0; i<100000000; i++)
  {
   if ((i%1000)==0)
   {
    System.out.println(thread + " " + i + " " + foo);
   }
   
   double r;
   r=Math.random();
   
   foo = foo + abs[(int)(((r * (abs.length-1))))];
   r=Math.random();
   
   foo = replaceAll(foo, ""+abs[(int)(((r * (abs.length-1))))], "");
  }
 }
}



Debug session



C:\eclipse\workspace\edgemaster>\mingw\bin\gdb test.exe
GNU gdb 5.1.1 (mingw experimental)
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 "mingw32"...
(gdb) run
Starting program: C:\eclipse\workspace\edgemaster/test.exe
Program received signal SIGSEGV, Segmentation fault.
0x0040d7bf in java::lang::String::init(JArray<wchar_t>*, int, int, bool) ()
(gdb) thread apply all bt
Thread 3 (thread 672.0x6d8):
#0  0x77f837c0 in ?? ()
#1  0x0042971a in GC_malloc_atomic ()
#2  0x004026fe in _Jv_AllocPtrFreeObject ()
#3  0x0040d6f9 in _Jv_AllocString ()
#4  0x0040d720 in _Jv_NewString ()
#5  0x0040131d in Test.replaceAll(java.lang.String, java.lang.String, java.lang.
String) (in=0xf925d0, a=0xf925b0, b=0xad3f90) at Test.java:0
#6  0x00401c81 in Test.stressGB(java.lang.String) (thread=0xadcb10)
    at Test.java:0
#7  0x00401dc4 in Test$1.run() (this=0xad5fc0) at Test.java:0
#8  0x00406b29 in java::lang::Thread::run() ()
#9  0x00418347 in _Jv_ThreadRun(java::lang::Thread*) ()
#10 0x00417a67 in _Z12really_startPv at 4 ()
#11 0x00455f08 in thread_start at 4 ()
#12 0x77e8b2d8 in _libwsock32_a_iname ()
Thread 2 (thread 672.0x930):
#0  0x77f837b2 in ?? ()
#1  0x77ea9c13 in _libwsock32_a_iname ()
#2  0x0040c4e8 in java::lang::Object::wait(long long, int) ()
#3  0x00403be4 in java::lang::Object::wait() ()
---Type <return> to continue, or q <return> to quit---
#4  0x0041392e in gnu::gcj::runtime::FinalizerThread::run() ()
#5  0x00418347 in _Jv_ThreadRun(java::lang::Thread*) ()
#6  0x00417a67 in _Z12really_startPv at 4 ()
#7  0x00455f08 in thread_start at 4 ()
#8  0x77e8b2d8 in _libwsock32_a_iname ()
Thread 1 (thread 672.0x8f8):
#0  0x0040d7bf in java::lang::String::init(JArray<wchar_t>*, int, int, bool) ()
#1  0x00403f45 in java::lang::String::String(java::lang::StringBuffer*) ()
#2  0x004063b8 in java::lang::StringBuffer::toString() ()
#3  0x004045bc in java::lang::String::valueOf(java::lang::Object*) ()
#4  0x0040145d in Test.replaceAll(java.lang.String, java.lang.String, java.lang.
String) (in=0xf6cee0, a=0xf6cec0, b=0xad3f90) at Test.java:0
#5  0x00401c81 in Test.stressGB(java.lang.String) (thread=0xad9938)
    at Test.java:0
#6  0x00401713 in Test.main(java.lang.String[]) (args=0xad7fe0) at Test.java:0
#7  0x0044f7fc in gnu::gcj::runtime::FirstThread::call_main() ()
#8  0x00413c32 in gnu::gcj::runtime::FirstThread::run() ()
#9  0x00418347 in _Jv_ThreadRun(java::lang::Thread*) ()
#10 0x00403652 in _Jv_RunMain(java::lang::Class*, char const*, int, char const**
, bool) ()
#11 0x00403798 in JvRunMain ()
#12 0x0040127b in main (argc=1, argv=0x6424e8) at c:/temp/ccUlcaaa.i:0
(gdb)
Display all 117 possibilities? (y or n)
(gdb) dom();
Undefined command: "dom".  Try "help".
(gdb)




C:\eclipse\workspace\edgemaster>\thisiscool-gcc\gcc-3.3\bin\gcj -v
Reading specs from \thisiscool-gcc\gcc-3.3\bin\..\lib\gcc-lib\mingw32\3.3\specs
Reading specs from \thisiscool-gcc\gcc-3.3\bin\..\lib\gcc-lib\mingw32\3.3\..\..\
..\libgcj.spec
rename spec lib to liborig
Configured with: /datal/gcc/gcc/configure --prefix=/datal/gcc/w32gcc/gcc --build
=i686-pc-linux-gnu --host=mingw32 --target=mingw32 --enable-languages=c,c++,java
 --with-gcc --with-gnu-as --with-gnu-ld --with-as=/datal/gcc/xgcc/bin/mingw32-as
 --with-ld=/datal/gcc/xgcc/bin/mingw32-ld --enable-threads=win32 --disable-nls -
-disable-win32-registry --disable-shared --disable-debug --disable-multilib --wi
thout-newlib --enable-libgcj --disable-java-awt --without-x --enable-java-gc=boe
hm --disable-libgcj-debug --enable-interpreter --enable-hash-synchronization : (
reconfigured)
Thread model: win32
gcc version 3.3 20030218 (prerelease)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]