Bug 10920 - Too many roots is reported for program, which shouldn't run out of memory
Summary: Too many roots is reported for program, which shouldn't run out of memory
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: libgcj (show other bugs)
Version: 3.3
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-05-21 21:53 UTC by oyvind.harboe
Modified: 2016-09-30 22:53 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-09-24 05:46:58


Attachments
Files needed to reproduce the problem (3.16 MB, application/x-zip-compressed)
2003-05-21 21:56 UTC, oyvind.harboe
Details

Note You need to log in before you can comment on or make changes to this bug.
Description oyvind.harboe 2003-05-21 21:53:24 UTC
In trying to track down a heap corruption problem (GDB has a warning
about heap corruption), I've stumbled across a weird failure.

"Too many root sets"

I think my test isn't eating memory, so why does the garbage 
collector go gaga?



gcj --main=TestSerial ..\scripts\native\modified_swt.jar
..\scripts\native\comm.jar -fjni -o ..\scripts\native\test2.exe
TestSerial.java


The various files required for this test are too big to post, 
but they can be downloaded here:

http://www.harboe.org/oyvind/rootsets.zip


import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
import javax.comm.CommPortIdentifier;
import javax.comm.NoSuchPortException;
import javax.comm.PortInUseException;
import javax.comm.SerialPort;
import javax.comm.UnsupportedCommOperationException;

public class TestSerial
{
	public void run() 
	{
		Display display = new Display();
		final Shell shell = new Shell(display);
		RowLayout layout = new RowLayout();
		layout.justify = true;
		layout.pack = true;
		shell.setLayout(layout);
		shell.setText("Hello GCJ World!");
		Label label = new Label(shell, SWT.CENTER);
		label.setText("Hello, GCJ World!");
		Button button=new Button(shell, SWT.NONE);
   button.setText("wweee!");
		shell.pack();
		shell.open ();

		
		try
		{
			CommPortIdentifier portId =
CommPortIdentifier.getPortIdentifier("COM2");

			SerialPort sPort = (SerialPort)
portId.open("transfer", 0);
			
			try
			{
				sPort.setSerialPortParams(19200,
SerialPort.DATABITS_8, 
				SerialPort.STOPBITS_1,
				 SerialPort.PARITY_NONE);
				
	
sPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
				
				InputStream sIn=sPort.getInputStream();
				OutputStream
sOut=sPort.getOutputStream();
			
			}
			finally
			{			
				sPort.close();
			}
		} catch (IOException e)
		{
			e.printStackTrace();
		} catch (NoSuchPortException e)
		{
			e.printStackTrace();
		} catch (PortInUseException e)
		{
			e.printStackTrace();
		} catch (UnsupportedCommOperationException e)
		{
			e.printStackTrace();
		}
		shell.dispose();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) display.sleep
();
		}
	   display.dispose ();
	}
	
	public static void main(String[] args)
	{
		// avoid dependency on the silly javax.comm.properties
file
		// works for Java Web Start *and* GCJ.
		String driverName = "com.sun.comm.Win32Driver";
		try
		{
			javax.comm.CommDriver commDriver =
				(javax.comm.CommDriver) Class
					.forName(driverName)
					.newInstance();
			commDriver.initialize();
		} catch (ClassNotFoundException e)
		{
			e.printStackTrace();
		} catch (InstantiationException e)
		{
			e.printStackTrace();
		} catch (IllegalAccessException e)
		{
			e.printStackTrace();
		}
		for (int i=0; i<1000; i++)
		{
			System.out.println("Test " + i);
			new TestSerial().run();
		}
	}
}
Comment 1 oyvind.harboe 2003-05-21 21:56:02 UTC
Created attachment 4048 [details]
Files needed to reproduce the problem
Comment 2 Andrew Pinski 2003-10-19 18:00:42 UTC
Does this happen any more on the mainline?
Comment 3 oyvind.harboe 2003-10-21 07:41:36 UTC
I can't test this on GCC 3.4 since it fails to compile. I believe this is a 
known regression(I've reported a very similar case earlier):



[lots of unreachable bytecode warnings deleted]
c:\temp/ccIvaaaa.s:1081731: Error: symbol `__GLOBAL__I__ZN10TestSerial6class$E'
is already defined



gcj --main=TestSerial modified_swt.jar comm.jar -fjni -o test3.exe 
TestSerial.java

Øyvind
Comment 4 oyvind.harboe 2003-11-24 19:20:20 UTC
With Mohans latest GCC 3.4 build, I can now compile again, though after 686 
iterations, I got "Too many root sets" and an exception.

Øyvind
Comment 5 oyvind.harboe 2003-11-24 19:26:49 UTC
Hmmm.... I get compilation errors when I try to compile the TestSerial.java 
class...



\thisiscool-gcc\gcc-3.4\bin\gcj -c TestSerial.java --classpath 
modifed_swt.jar;comm.jar

TestSerial.java:11: error: Class or interface 
`org.eclipse.swt.layout.RowLayout' not found in import.
   import org.eclipse.swt.layout.RowLayout;
          ^
TestSerial.java:22: error: Type `Display' not found in the declaration of the 
local variable `display'.
   		Display display = new Display();
                   ^
TestSerial.java:23: error: Type `Shell' not found in the declaration of the 
local variable `shell'.
   		final Shell shell = new Shell(display);
                         ^
TestSerial.java:24: error: Type `RowLayout' not found in the declaration of the 
local variable `layout'.
   		RowLayout layout = new RowLayout();
                   ^
TestSerial.java:29: error: Type `Label' not found in the declaration of the 
local variable `label'.
   		Label label = new Label(shell, SWT.CENTER);
                   ^
TestSerial.java:31: error: Type `Button' not found in the declaration of the 
local variable `button'.
   		Button button=new Button(shell, SWT.NONE);
                   ^
6 errors
Comment 6 oyvind.harboe 2003-11-24 19:36:30 UTC
Ooops. Ignore that last comment. It was a command line gaffe. The correct 
command line is:

\thisiscool-gcc\gcc-3.4\bin\gcj -c -classpath modified_swt.jar;comm.jar 
TestSerial.java

The app runs fine w/JRE 1.4.2_01. I modified TestSerial.java to run 10000 
iterations.

java -Djava.library.path=. -classpath modified_swt.jar;comm.jar;. TestSerial


Comment 7 oyvind.harboe 2003-11-24 19:40:01 UTC
Its not very informative, but here is the GDB output:

Test 642

Program received signal SIGTRAP, Trace/breakpoint trap.
0x77fa144c in ?? ()
(gdb) thread apply all bt

Thread 2 (thread 4172.0xfe8):
#0  0x77f9323e in ?? ()
#1  0x7c59a059 in WaitForMultipleObjectsEx ()
   from /cygdrive/c/winnt/system32/KERNEL32.DLL
#2  0x7c599f6c in WaitForMultipleObjects ()
   from /cygdrive/c/winnt/system32/KERNEL32.DLL
#3  0x013cfdb4 in ?? ()
#4  0x00000001 in ?? ()

Thread 1 (thread 4172.0x1040):
#0  0x77fa144c in ?? ()
#1  0x007300c3 in GC_abort ()
#2  0x0090f0fb in _Utf62 ()
(gdb) quit
The program is running.  Exit anyway? (y or n) y
Comment 8 oyvind.harboe 2003-11-25 07:22:48 UTC
The problem is discussed in this thread.

http://gcc.gnu.org/ml/java/2003-11/msg00279.html
Comment 9 Andrew Pinski 2016-09-30 22:53:51 UTC
Closing as won't fix as libgcj (and the java front-end) has been removed from the trunk.