public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* GCJ deadlock on ARMLinux
@ 2009-01-26  7:32 Michael Jakobs
  2009-01-26 10:59 ` Andrew Haley
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Jakobs @ 2009-01-26  7:32 UTC (permalink / raw)
  To: gcc-help

[-- Attachment #1: Type: text/plain, Size: 760 bytes --]

Hello,

Hopefully, this is the right mailing list for my problems, if not please 
let me know which one is the better list for my request.

I am using:

gcj 4.0.2
build with crosstool with glibc-2.3.2
for an embedded ARM Box with Linux 2.6.14


I had some deadlock problems on a big application and couldn't find the 
error, so I started working on a small test program.
This program is just a (very) easy application, which exchanges data 
between a TCP Client and Server. The error is:
This data sharing works for several times, but after exchanging some 
packets (might be 3 or even a thousand), the client stops before calling 
or inside the method socket.write(...).

For better understanding, I have attached the code.


Thank you for your help

Michael

[-- Attachment #2: Client.java --]
[-- Type: text/java, Size: 2639 bytes --]

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.Socket;


public class Client extends Thread {
	private static String str_data = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	private        int    in_port;
	
	public Client( int in_serverport ) {
		in_port = in_serverport;
		this.start();
	}
	
	public void run() {
		while ( true ) {
			Socket ds_socket = null;
			try {
				ds_socket = new Socket("localhost", in_port);    
				DataInputStream  in  = new DataInputStream ( ds_socket.getInputStream());
				DataOutputStream out = new DataOutputStream( ds_socket.getOutputStream());

				
				//-------------------------------------------------------------
				// sending data
				//-------------------------------------------------------------
				if ( start.bo_printmess ) {
					System.out.println("CL - write start");
					System.out.flush();
				}
				out.writeUTF(str_data);
				out.flush();
				if ( start.bo_printmess ) {
					System.out.println("CL - write ready");
					System.out.flush();
				}
				if ( start.bo_useyield ) {
					Thread.yield();
				}
				
				
				//-------------------------------------------------------------
				// receive data
				//-------------------------------------------------------------
				if ( start.bo_printmess ) {
					System.out.println("CL - read start");
					System.out.flush();
				}				
				String str_data = in.readUTF();
				if ( start.bo_printmess ) {
					System.out.println("CL - read ready");
					System.out.flush();
				}
				if ( start.bo_useyield ) {
					Thread.yield();
				}
				if ( start.bo_countruns ) {
					start.m_count( "CL - count " );
				}
				
				
				//-------------------------------------------------------------
				// print length of received data
				//-------------------------------------------------------------
				if ( start.bo_printrec ) {
					System.out.println("CL - received " + str_data.length() + " bytes" );
					System.out.flush();
				}
				
				
				//-------------------------------------------------------------
				// close socket
				//-------------------------------------------------------------
				if ( start.bo_printmess ) {
					System.out.println("CL - close start");
					System.out.flush();
				}
				in.close();
				out.close();
				ds_socket.close();
				ds_socket = null;
				if ( start.bo_useyield ) {
					Thread.yield();
				}
				if ( start.bo_printmess ) {
					System.out.println("CL - close ready");
					System.out.flush();
				}
				
			} catch ( Throwable e ) {
				System.out.println("CL - ");
				e.printStackTrace();
				System.out.flush();
			}
		}
	}

}

[-- Attachment #3: Server.java --]
[-- Type: text/java, Size: 4272 bytes --]

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.ServerSocket;
import java.net.Socket;


public class Server extends Thread {
	private ServerSocket     ds_serversocket;
	
	public Server ( int in_serverport ) {
		try {
			ds_serversocket = new ServerSocket(in_serverport);
			this.start();
		} catch( Throwable ds_e ) {
			System.out.println(ds_e.getMessage());
			System.out.flush();
		}
	}
	
	public void run(){
		m_run();
	}
	
	private void m_run() {
		try {
			Socket ds_socket = null;
			while ( true ) {
				//-------------------------------------------------------------
				// wait for a connection
				//-------------------------------------------------------------
				if ( start.bo_printmess ) {
					System.out.println("SV - accept start");
					System.out.flush();
				}
				ds_socket = ds_serversocket.accept();
				if ( start.bo_printmess ) {
					System.out.println("SV - accept ready");
					System.out.flush();
				}
				if ( start.bo_countruns ) {
					start.m_count( "SV - count " );
				}
				m_server( ds_socket );
				
				//-------------------------------------------------------------
				// close socket
				//-------------------------------------------------------------
				if ( start.bo_printmess ) {
					System.out.println("SV - close start");
					System.out.flush();				
				}
				ds_socket.close();
				ds_socket = null;
				if ( start.bo_printmess ) {
					System.out.println("SV - close ready");
					System.out.flush();				
				}
				
				//-------------------------------------------------------------
				// print memory overview
				//-------------------------------------------------------------
				if ( start.bo_printmem ) {
					System.out.println( "Free mem:  " + Runtime.getRuntime().freeMemory()  );
					System.out.println( "Total mem: " + Runtime.getRuntime().totalMemory() );
				}
				
				//-------------------------------------------------------------
				// call garbage collector
				//-------------------------------------------------------------
				if ( start.bo_usegc ) {
					System.out.println("GC - start");
					System.out.flush();
					System.gc();
					System.out.println("GC - ready");
					System.out.flush();
				}
				
				//-------------------------------------------------------------
				// print memory overview
				//-------------------------------------------------------------
				if ( start.bo_printmem ) {
					System.out.println( "Free mem:  " + Runtime.getRuntime().freeMemory()  );
					System.out.println( "Total mem: " + Runtime.getRuntime().totalMemory() );
				}
			}
		} catch ( Throwable e ){ 
			System.out.println( e.getMessage() );
			System.out.flush();	
		}
	}
	
	private void m_server( Socket ds_socket ) {
		try {
			DataInputStream  ds_in  = new DataInputStream ( ds_socket.getInputStream()  );
			DataOutputStream ds_out = new DataOutputStream( ds_socket.getOutputStream() );
			
			
			//-------------------------------------------------------------
			// receive data
			//-------------------------------------------------------------
			if ( start.bo_printmess ) {
				System.out.println("SV - read start");
				System.out.flush();
			}
			String str_data = ds_in.readUTF();
			if ( start.bo_printmess ) {				
				System.out.println("SV - read ready");
				System.out.flush();
			}
			if ( start.bo_useyield ) {
				Thread.yield();
			}
			
			//-------------------------------------------------------------
			// print length of received data
			//-------------------------------------------------------------
			if ( start.bo_printrec ) {
				System.out.println("SV - received " + str_data.length() + " bytes" );
				System.out.flush();
			}
				
			//-------------------------------------------------------------
			// sending data back:
			//-------------------------------------------------------------
			if ( start.bo_printmess ) {
				System.out.println("SV - write start");
				System.out.flush();
			}
			ds_out.writeUTF(str_data);
			ds_out.flush();
			if ( start.bo_printmess ) {
				System.out.println("SV - write ready");
				System.out.flush();
			}
			if ( start.bo_useyield ) {
				Thread.yield();
			}
		}  catch ( Throwable e ){ 
			System.out.println("SV - Throwable: "+e.getMessage());
			System.out.flush();
		}
	}


}


[-- Attachment #4: start.java --]
[-- Type: text/java, Size: 1605 bytes --]



public class start {
	private static int     in_serverport = 12345;
	private static long    in_counter;
	
	public  static boolean bo_useyield   = true;	// use Thread.yield() after send and receive
	public  static boolean bo_usegc      = false;	// call garbage collector explicit
	public  static boolean bo_printmem   = false;	// print a memory overview
	public  static boolean bo_printmess  = true;	// print message before send and receive
	public  static boolean bo_printrec   = false;	// print length of received data
	public  static boolean bo_countruns  = false;   // count runs
	
	public static void main(String[] args) {
		in_counter = 0;
		
		System.out.println( "Configuration:");
		System.out.println( "==============");
		System.out.println( "    Use yield:               " + (bo_useyield   ? "yes" : "no") );
		System.out.println( "    Call GC explicit:        " + (bo_usegc      ? "yes" : "no") );
		System.out.println( "    Print Memory overview:   " + (bo_printmem   ? "yes" : "no") );
		System.out.println( "    Print send/rec Messages: " + (bo_printmess  ? "yes" : "no") );
		System.out.println( "    Print length rec data:   " + (bo_printrec   ? "yes" : "no") );
		System.out.println( "    Count runs:              " + (bo_countruns  ? "yes" : "no") );
		System.out.println( "" );
		System.out.println( "" );
		System.out.flush();
		
		// start Server:
		new Server( in_serverport );
		
		// start client:
		new Client(in_serverport);
		
	}
	
	public static void m_count( String str_prefix ) {
		System.out.println( str_prefix + in_counter );
		System.out.flush();
		in_counter++;
	}
}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: GCJ deadlock on ARMLinux
  2009-01-26  7:32 GCJ deadlock on ARMLinux Michael Jakobs
@ 2009-01-26 10:59 ` Andrew Haley
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Haley @ 2009-01-26 10:59 UTC (permalink / raw)
  To: Michael Jakobs; +Cc: gcc-help

Michael Jakobs wrote:

> Hopefully, this is the right mailing list for my problems, if not please
> let me know which one is the better list for my request.

This is the list.

> I am using:
> 
> gcj 4.0.2
> build with crosstool with glibc-2.3.2
> for an embedded ARM Box with Linux 2.6.14
> 
> 
> I had some deadlock problems on a big application and couldn't find the
> error, so I started working on a small test program.
> This program is just a (very) easy application, which exchanges data
> between a TCP Client and Server. The error is:
> This data sharing works for several times, but after exchanging some
> packets (might be 3 or even a thousand), the client stops before calling
> or inside the method socket.write(...).
> 
> For better understanding, I have attached the code.

I've run this for a while on gcj 4.3.1, kernel 2.6.22-3-iop32x ARM EABI
GNU/Linux, with no problems.

gcj 4.0.2 is very old.  I fixed a lot of problems in Sep 2007, and the
first gcj release with these fixes is 4.3.x.  This release requires ARM
EABI, which we need to properly support ARM stack unwinding.

Have you run the gcj test suite?  I suppose not, as I'm not aware of
any way of running the compiler test suites on crosstool.  I suspect
you'd see a lot of problems.

Andrew.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-01-26 10:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-26  7:32 GCJ deadlock on ARMLinux Michael Jakobs
2009-01-26 10:59 ` Andrew Haley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).