public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: java/4031: Socket code failing with null ptr exception
@ 2001-08-16 10:20 tromey
0 siblings, 0 replies; 6+ messages in thread
From: tromey @ 2001-08-16 10:20 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, java-prs, nobody, olson, tromey
Synopsis: Socket code failing with null ptr exception
Responsible-Changed-From-To: unassigned->tromey
Responsible-Changed-By: tromey
Responsible-Changed-When: Thu Aug 16 10:20:35 2001
Responsible-Changed-Why:
I've handled it.
State-Changed-From-To: open->closed
State-Changed-By: tromey
State-Changed-When: Thu Aug 16 10:20:35 2001
State-Changed-Why:
I believe this is already fixed in gcc 3.0 and 3.1.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=4031&database=gcc
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: java/4031: Socket code failing with null ptr exception
@ 2001-08-16 10:36 Robert Olson
0 siblings, 0 replies; 6+ messages in thread
From: Robert Olson @ 2001-08-16 10:36 UTC (permalink / raw)
To: tromey; +Cc: gcc-prs
The following reply was made to PR java/4031; it has been noted by GNATS.
From: Robert Olson <olson@mcs.anl.gov>
To: tromey@redhat.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: java/4031: Socket code failing with null ptr exception
Date: Thu, 16 Aug 2001 12:32:16 -0500
Very cool. I'll have to give them a try.
thanks,
--bob
At 11:47 AM 8/16/2001 -0600, Tom Tromey wrote:
> >>>>> "Robert" == olson <olson@mcs.anl.gov> writes:
>
> >> Release: gcj 2.96
>
>I tried `fo' using gcj 3.1. It worked fine.
>I also tried using gcj 3.0, and that worked too.
>So I think whatever the bug was, it has since been fixed.
>
>Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: java/4031: Socket code failing with null ptr exception
@ 2001-08-16 10:26 Tom Tromey
0 siblings, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2001-08-16 10:26 UTC (permalink / raw)
To: tromey; +Cc: gcc-prs
The following reply was made to PR java/4031; it has been noted by GNATS.
From: Tom Tromey <tromey@redhat.com>
To: olson@mcs.anl.gov
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: java/4031: Socket code failing with null ptr exception
Date: 16 Aug 2001 11:47:58 -0600
>>>>> "Robert" == olson <olson@mcs.anl.gov> writes:
>> Release: gcj 2.96
I tried `fo' using gcj 3.1. It worked fine.
I also tried using gcj 3.0, and that worked too.
So I think whatever the bug was, it has since been fixed.
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: java/4031: Socket code failing with null ptr exception
@ 2001-08-15 14:26 Tom Tromey
0 siblings, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2001-08-15 14:26 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR java/4031; it has been noted by GNATS.
From: Tom Tromey <tromey@redhat.com>
To: olson@mcs.anl.gov
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: java/4031: Socket code failing with null ptr exception
Date: 15 Aug 2001 15:49:12 -0600
>>>>> ">" == olson <olson@mcs.anl.gov> writes:
>> gcj -g -v -o fo --main=fo fo.java
Could you send fo.java to me? Please CC gcc-gnats, so that it is
included in the PR.
Thanks,
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: java/4031: Socket code failing with null ptr exception
@ 2001-08-15 14:26 Robert Olson
0 siblings, 0 replies; 6+ messages in thread
From: Robert Olson @ 2001-08-15 14:26 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR java/4031; it has been noted by GNATS.
From: Robert Olson <olson@mcs.anl.gov>
To: tromey@redhat.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: java/4031: Socket code failing with null ptr exception
Date: Wed, 15 Aug 2001 16:21:47 -0500
--=====================_65630141==_.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed
At 03:49 PM 8/15/2001 -0600, Tom Tromey wrote:
> >>>>> ">" == olson <olson@mcs.anl.gov> writes:
>
> >> gcj -g -v -o fo --main=fo fo.java
>
>Could you send fo.java to me? Please CC gcc-gnats, so that it is
>included in the PR.
Here it is -- I'd put it there on the file upload on the bugs page, guess
it didn't upload.
--bob
/**
* WebView.java
*
* Response to query from web browsers
*
* @version 0.6 04/03/2000
* @author Kai Chen, NLANR
*/
import java.net.*;
import java.io.*;
import java.util.*;
public class fo
{
private boolean verboseMode = true;
private ServerSocket listenSock = null;
private StringBuffer sbuf = null; // for storing web reply
public static void main (String args[])
{
fo w = new fo();
w.run();
}
fo()
{
System.out.println("start webiew");
try {
listenSock = new ServerSocket(9999, 20); // set backlog
} catch (BindException ex) {
System.out.println("WebView: error creating listening socket - "
+ ex.getMessage());
} catch (IOException ex) {
System.out.println("WebView: error creating listening socket - "
+ ex.getMessage());
}
}
public void run()
{
Socket sock = null;
// loop to listen for incoming connections
while (true) {
// accept a connection
try {
sock = listenSock.accept();
} catch (IOException ex) {
if (verboseMode) System.out.println("WebView: error
accepting connection - "
+ ex.getMessage());
sock = null;
continue; // ignore this request
}
try {
processRequest(sock); // reply to the request
} catch (Exception ex) {
if (verboseMode) System.out.println("WebView processreq
threw " + ex + ": " + ex.getMessage());
ex.printStackTrace();
// ignore this request
}
try {
sock.close();
} catch (IOException ex) {
if (verboseMode)
System.out.println("WebView: close socket error - " +
ex.getMessage());
}
sock = null; // for garbage collection
} // end of while
}
/*
* cleanup
*/
protected void finalize() {
try {
listenSock.close();
} catch (IOException ex) {}
}
/*
* read the request and send a reply via TCP as a html page
*/
private void processRequest(Socket sock) throws Exception
{
// reads the web request
BufferedReader sockInput = new BufferedReader
(new InputStreamReader(sock.getInputStream()));
String displayOption = "loss"; // default
while (true) {
String line = sockInput.readLine();
System.out.println("webview got " + line);
if (line.startsWith("GET")) {
int first = line.indexOf(' ');
int second = line.indexOf(' ', first + 1);
System.out.println("have " + first + " " + second);
if (second< 0)
displayOption = line.substring(first + 2).toLowerCase();
else
displayOption = line.substring(first + 2,
second).toLowerCase();
//while (sockInput.ready())
// sockInput.readLine(); // discard the rest of the request
break;
}
}
System.out.println("start me up");
BufferedWriter sockOutput = new BufferedWriter
(new OutputStreamWriter(sock.getOutputStream()));
// PrintWriter pwriter = new PrintWriter(sockOutput);
BufferedWriter pwriter = sockOutput;
pwriter.write("Content-type: text/plain\n\n");
pwriter.write("Got " + displayOption);
System.out.println("closedown");
try {
// pwriter.close();
sockOutput.flush();
sockOutput.close();
sockInput.close();
} catch (IOException ex) {
if (verboseMode)
System.out.println("WebView: stream close error - " +
ex.getMessage());
}
return;
}
}
--=====================_65630141==_.ALT
Content-Type: text/html; charset="us-ascii"
<html>
At 03:49 PM 8/15/2001 -0600, Tom Tromey wrote:<br>
<blockquote type=cite cite>>>>>> ">" ==
olson <olson@mcs.anl.gov> writes:<br>
<br>
>> gcj -g -v -o fo --main=fo fo.java<br>
<br>
Could you send fo.java to me? Please CC gcc-gnats, so that it
is<br>
included in the PR.</blockquote><br>
Here it is -- I'd put it there on the file upload on the bugs page, guess
it didn't upload.<br>
<br>
--bob<br>
<br>
/**<br>
* WebView.java <br>
*<br>
* Response to query from web browsers<br>
* <br>
* @version 0.6 04/03/2000<br>
* @author Kai Chen, NLANR<br>
*/<br>
<br>
import java.net.*;<br>
import java.io.*;<br>
import java.util.*;<br>
<br>
public class fo<br>
{<br>
private boolean verboseMode = true;<br>
private ServerSocket listenSock = null;<br>
<br>
private StringBuffer sbuf = null; // for
storing web reply<br>
<br>
public static void main (String args[])<br>
{<br>
fo w = new fo();<br>
w.run();<br>
}<br>
<br>
fo()<br>
{<br>
<x-tab> </x-tab>System.out.println("start
webiew");<br>
<br>
try {<br>
listenSock = new ServerSocket(9999, 20); // set backlog <br>
} catch (BindException ex)
{<br>
System.out.println("WebView: error creating listening socket -
"<br>
+ ex.getMessage());<br>
} catch (IOException ex)
{<br>
System.out.println("WebView: error creating listening socket -
"<br>
+ ex.getMessage());<br>
}<br>
}<br>
<br>
public void run()<br>
{<br>
<x-tab> </x-tab>Socket
sock = null;<br>
<br>
// loop to listen for incoming
connections<br>
while (true) {<br>
//
accept a connection<br>
try
{<br>
sock = listenSock.accept();<br>
}
catch (IOException ex) {<br>
if (verboseMode) System.out.println("WebView: error accepting
connection - "<br>
<x-tab> </x-tab><x-tab> </x-tab><x-tab> </x-tab><x-tab> </x-tab><x-tab> </x-tab><x-tab> </x-tab>
+ ex.getMessage());<br>
sock = null;<br>
continue; // ignore this request<br>
}<br>
<br>
try
{<br>
processRequest(sock); // reply to the request<br>
}
catch (Exception ex) {<br>
if (verboseMode) System.out.println("WebView processreq threw "
+ ex + ": " + ex.getMessage());<br>
ex.printStackTrace();<br>
// ignore this request<br>
}<br>
<br>
try
{<br>
<x-tab> </x-tab><x-tab> </x-tab>sock.close();<br>
}
catch (IOException ex) {<br>
<x-tab> </x-tab><x-tab> </x-tab>if
(verboseMode) <br>
<x-tab> </x-tab><x-tab> </x-tab>
System.out.println("WebView: close socket error - " +
ex.getMessage());<br>
<x-tab> </x-tab>
}<br>
<br>
sock =
null; // for garbage collection<br>
<br>
} // end of while<br>
<br>
}<br>
<br>
<br>
/*<br>
* cleanup<br>
*/<br>
protected void finalize() {<br>
try {<br>
listenSock.close();<br>
} catch (IOException ex)
{}<br>
}<br>
<br>
<br>
/*<br>
* read the request and send a reply via TCP as a
html page<br>
*/<br>
<br>
private void processRequest(Socket sock) throws
Exception<br>
{<br>
// reads the web request<br>
<x-tab> </x-tab>BufferedReader
sockInput = new BufferedReader<br>
<x-tab> </x-tab>
(new InputStreamReader(sock.getInputStream()));<br>
<x-tab> </x-tab>String
displayOption = "loss"; // default<br>
<br>
<x-tab> </x-tab>while
(true) {<br>
<x-tab> </x-tab>
String line = sockInput.readLine();<br>
<x-tab> </x-tab>
System.out.println("webview got " + line);<br>
<x-tab> </x-tab>
if (line.startsWith("GET")) {<br>
<x-tab> </x-tab><x-tab> </x-tab>int
first = line.indexOf(' ');<br>
<x-tab> </x-tab><x-tab> </x-tab>int
second = line.indexOf(' ', first + 1);<br>
System.out.println("have " + first + " " +
second);<br>
if (second< 0)<br>
<x-tab> </x-tab><x-tab> </x-tab>displayOption
= line.substring(first + 2).toLowerCase();<br>
else<br>
<x-tab> </x-tab><x-tab> </x-tab>displayOption
= line.substring(first + 2, second).toLowerCase();<br>
<x-tab> </x-tab><x-tab> </x-tab>//while
(sockInput.ready()) <br>
<x-tab> </x-tab><x-tab> </x-tab>//
sockInput.readLine(); // discard the rest of the request<br>
<x-tab> </x-tab><x-tab> </x-tab>break;<br>
<x-tab> </x-tab>
}<br>
<x-tab> </x-tab>}<br>
<x-tab> </x-tab>System.out.println("start
me up");<br>
<br>
<br>
<x-tab> </x-tab>BufferedWriter
sockOutput = new BufferedWriter<br>
<x-tab> </x-tab>
(new OutputStreamWriter(sock.getOutputStream()));<br>
//<x-tab> </x-tab>PrintWriter pwriter
= new PrintWriter(sockOutput);<br>
<x-tab> </x-tab>BufferedWriter
pwriter = sockOutput;<br>
<br>
pwriter.write("Content-type: text/plain\n\n");<br>
pwriter.write("Got " + displayOption);<br>
<br>
<x-tab> </x-tab>System.out.println("closedown");<br>
<x-tab> </x-tab>try
{<br>
<x-tab> </x-tab>
// pwriter.close();<br>
<x-tab> </x-tab>
sockOutput.flush();<br>
<x-tab> </x-tab>
sockOutput.close();<br>
<x-tab> </x-tab>
sockInput.close();<br>
<x-tab> </x-tab>} catch
(IOException ex) {<br>
<x-tab> </x-tab>
if (verboseMode)<br>
<x-tab> </x-tab><x-tab> </x-tab>System.out.println("WebView:
stream close error - " + ex.getMessage());<br>
<x-tab> </x-tab>}<br>
<br>
return;<br>
}<br>
}<br>
</html>
--=====================_65630141==_.ALT--
^ permalink raw reply [flat|nested] 6+ messages in thread
* java/4031: Socket code failing with null ptr exception
@ 2001-08-15 5:46 olson
0 siblings, 0 replies; 6+ messages in thread
From: olson @ 2001-08-15 5:46 UTC (permalink / raw)
To: gcc-gnats
>Number: 4031
>Category: java
>Synopsis: Socket code failing with null ptr exception
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Aug 15 05:46:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Robert Olson
>Release: gcj 2.96
>Organization:
>Environment:
RedHat Linux 7.1 on i386
>Description:
A simple socket code to read a web browser request crashes with an exception. The code works fine under Sun JDK1.2.2.
gcj -g -v -o fo --main=fo fo.java
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/libgcj.spec
rename spec lib to liborig
rename spec startfile to startfileorig
gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-81)
/usr/lib/gcc-lib/i386-redhat-linux/2.96/jc1 fo.java -fno-use-divide-subroutine -fasynchronous-exceptions -quiet -dumpbase fo.java -g -version -o /tmp/ccwYvix0.s
GNU Java version 2.96 20000731 (Red Hat Linux 7.1 2.96-81) (i386-redhat-linux) compiled by GNU C version 2.96 20000731 (Red Hat Linux 7.1 2.96-81).
as -V -Qy -o /tmp/ccBr5Wr6.o /tmp/ccwYvix0.s
GNU assembler version 2.10.91 (i386-redhat-linux) using BFD version 2.10.91.0.2
/usr/lib/gcc-lib/i386-redhat-linux/2.96/jvgenmain fo /tmp/ccOqLhWimain.i
/usr/lib/gcc-lib/i386-redhat-linux/2.96/cc1 /tmp/ccOqLhWimain.i -quiet -dumpbase fo.c -g -version -o /tmp/ccfNRl1umain.s
GNU C version 2.96 20000731 (Red Hat Linux 7.1 2.96-81) (i386-redhat-linux) compiled by GNU C version 2.96 20000731 (Red Hat Linux 7.1 2.96-81).
as -V -Qy -o /tmp/ccaZyNRJmain%O /tmp/ccfNRl1umain.s
GNU assembler version 2.10.91 (i386-redhat-linux) using BFD version 2.10.91.0.2
/usr/lib/gcc-lib/i386-redhat-linux/2.96/collect2 -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o fo /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crti.o /usr/lib/gcc-lib/i386-redhat-linux/2.96/crtbegin.o -u __rethrow -u __frame_state_for -lgcc -L/usr/lib/gcc-lib/i386-redhat-linux/2.96 -L/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../.. /tmp/ccBr5Wr6.o /tmp/ccaZyNRJmain%O -lgcc -lgcj -lm -lgcjgc -lpthread -lzgcj -ldl -lc -lgcc /usr/lib/gcc-lib/i386-redhat-linux/2.96/crtend.o /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crtn.o
$ ./fo
start webiew
webview got GET /asdf HTTP/1.0
have 3 9
start me up
closedown
WebView processreq threw java.lang.NullPointerException: null
java.lang.NullPointerException
at 0x4010b779: _Jv_ThrowSignal (/usr/lib/libgcj.so.1)
at 0x4010b7b2: _Jv_ThrowSignal (/usr/lib/libgcj.so.1)
at 0x40173f5a: java::lang::StringBuffer::ensureCapacity_unsynchronized(int) (/usr/lib/libgcj.so.1)
at 0x40173953: java::lang::StringBuffer::append(java::lang::String *) (/usr/lib/libgcj.so.1)
at 0x0804cbe1: __frame_state_for (./fo)
at 0x0804c2c9: __frame_state_for (./fo)
at 0x0804c271: __frame_state_for (./fo)
at 0x401ce21d: gnu::gcj::runtime::FirstThread::run(void) (/usr/lib/libgcj.so.1)
at 0x401d7d36: java::lang::Thread::run_(java::lang::Object *) (/usr/lib/libgcj.so.1)
at 0x401e814d: _Jv_ThreadSetPriority(_Jv_Thread_t *, int) (/usr/lib/libgcj.so.1)
at 0x403094a0: GC_start_routine (/usr/lib/libgcjgc.so.1)
at 0x40322bfd: pthread_detach (/lib/i686/libpthread.so.0)
at 0x4042977a: __clone (/lib/i686/libc.so.6)
WebView: close socket error - Bad file descriptor
>How-To-Repeat:
Compile and run, then either point a web browser to port 9999 on that host or telnet to it and type the request of the form "GET /asdf HTTP/1.0":
% telnet host 9999
Trying hostip...
Connected to host.
Escape character is '^]'.
GET /asdf HTTP/1.0
Content-type: text/plain
Got asdfConnection closed by foreign host.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2001-08-16 10:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-16 10:20 java/4031: Socket code failing with null ptr exception tromey
-- strict thread matches above, loose matches on Subject: below --
2001-08-16 10:36 Robert Olson
2001-08-16 10:26 Tom Tromey
2001-08-15 14:26 Robert Olson
2001-08-15 14:26 Tom Tromey
2001-08-15 5:46 olson
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).