This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Crash in garbage collection(?) under GCC 3.3 & GCC 3.4
- From: Øyvind Harboe <oyvind dot harboe at zylin dot com>
- To: <java at gcc dot gnu dot org>
- Date: Mon, 21 Jul 2003 09:16:23 +0200
- Subject: Crash in garbage collection(?) under GCC 3.3 & GCC 3.4
This as Good Old crash still with us. :-)
I found it while looking for something else, and fortunally it
doesn't affect my app, but its an interesting bug.
The small app below crashes. All it does are some simple string
maniuplations w/multithreading...
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10746
Øyvind
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))))], "");
}
}
}