This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug libgcj/10746] [3.3 regression] [win32] garbage collection crash in GCJ


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10746



------- Additional Comments From oyvind dot harboe at zylin dot com  2003-07-24 09:02 -------
I've made a slightly different version of my test program.

I saw an intriguing difference in behaviour: it produced a null pointer 
exception instead of a GP fault.

When I tried to catch the problem in GDB, I got the stack trace below, which 
smells different than what I've seen before.


Program received signal SIGSEGV, Segmentation fault.
0x00434325 in _ZN4java4lang6System9arraycopyEPNS0_6ObjectEiS3_ii ()
(gdb) thread apply all bt

Thread 3 (thread 2932.0xc98):
#0  0x7ffe0304 in ?? ()
#1  0x0042d523 in GC_malloc_atomic ()
#2  0x004029e3 in _Jv_AllocPtrFreeObject ()
#3  0x0040bc60 in _Jv_AllocString ()
#4  0x0040bc96 in _Jv_NewString ()
#5  0x004013e9 in Test.replaceAll(java.lang.String, java.lang.String, java.lang.
String) (in=0xec86a0, a=0xec8680, b=0xc73f90) at Test.java:10
#6  0x00401a9d in Test.stressGB(java.lang.String) (thread=0xc7cb10) at Test.java
:62
#7  0x004012cf in Test$1.run() (this=0xc75fc0) at Test.java:34
#8  0x004075a8 in _ZN4java4lang6Thread3runEv ()
#9  0x004195b7 in _Z13_Jv_ThreadRunPN4java4lang6ThreadE ()
#10 0x00418b92 in _Z12really_startPv@4 ()
#11 0x004602df in thread_start@4 ()
#12 0x77e7d33b in RegisterWaitForInputIdle () from /ecos-C/WINDOWS/system32/kern
el32.dll

Thread 2 (thread 2932.0x9dc):
#0  0x7ffe0304 in ?? ()
#1  0x77e75faa in WaitForMultipleObjects () from /ecos-C/WINDOWS/system32/kernel
32.dll
#2  0x00411622 in _ZN4java4lang6Object4waitExi ()
#3  0x00404149 in _ZN4java4lang6Object4waitEv ()
#4  0x00413ff9 in _ZN3gnu3gcj7runtime15FinalizerThread3runEv ()
#5  0x004195b7 in _Z13_Jv_ThreadRunPN4java4lang6ThreadE ()
#6  0x00418b92 in _Z12really_startPv@4 ()
#7  0x004602df in thread_start@4 ()
#8  0x77e7d33b in RegisterWaitForInputIdle () from /ecos-C/WINDOWS/system32/kern
el32.dll

Thread 1 (thread 2932.0x4b4):
#0  0x00434325 in _ZN4java4lang6System9arraycopyEPNS0_6ObjectEiS3_ii ()
#1  0x00406fb4 in _ZN3gnu3gcj7runtime12StringBuffer29ensureCapacity_unsynchroniz
edEi ()
#2  0x00406f04 in _ZN3gnu3gcj7runtime12StringBuffer6appendEPN4java4lang6StringE
()
#3  0x00401455 in Test.replaceAll(java.lang.String, java.lang.String, java.lang.
String) (in=0x10f3630, a=0x10f3610, b=0xc73f90) at Test.java:13
#4  0x00401a9d in Test.stressGB(java.lang.String) (thread=0xc79938) at Test.java
:62
#5  0x004016ef in Test.main(java.lang.String[]) (args=0xc77fe0) at Test.java:39
#6  0x0045884b in _ZN3gnu3gcj7runtime11FirstThread9call_mainEv ()
#7  0x00414342 in _ZN3gnu3gcj7runtime11FirstThread3runEv ()
#8  0x004195b7 in _Z13_Jv_ThreadRunPN4java4lang6ThreadE ()
#9  0x00403b21 in _Z11_Jv_RunMainPN4java4lang5ClassEPKciPS4_b ()
#10 0x00403c5f in JvRunMain ()
#11 0x00401292 in main (argc=1, argv=0x3d2440) at C:/DOCUME~1/oyvind/LOCALS~1/Te
mp/cc4Ucaaa.i:11
(gdb)


public class Test
{
	static public String replaceAll(String in, String a, String b)
	{
		String t = "";
		int i;
		i = 0; 
		while (i < in.length() - a.length())
		{
			String c = in.substring(i, i + a.length());
			if (c.equals(a))
			{
				t += b;
				i = i + a.length();
			} else
			{
				t += in.substring(i, i + 1);
				i++;
			}
		}
		if (i < in.length())
		{
			t += in.substring(i, in.length());
		}
		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 final char[] abs = { 'a', 'b', 'c', 'd', 'e', 'f', 'g' };
	static char rndChar()
	{
		double r = Math.random();
		return abs[Math.min(abs.length - 1, (int) (r * abs.length ))];
	}

	static void stressGB(String thread)
	{

		String foo = "";
		for (int i = 0; i < 100000000; i++)
		{
			if ((i % 1000) == 0)
			{
				System.out.println(thread + " " + i + " " + 
foo);
			}

			foo = foo + rndChar();
			foo = replaceAll(foo, "" + rndChar(), "");
		}
	}
}


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