-
Bug
-
Resolution: Cannot Reproduce
-
P2
-
None
-
1.0
-
sparc
-
solaris_2.4
drawString should have better runtime error handling so that a bogus
argument to drawString doesn't cause the applet to hang.
overpaint.java is:
import java.lang.*;
import java.awt.*;
import java.applet.*;
/**
* Try to crash AWT by asking it to draw a huge string
*
* AWT should throw an exception, probably, but instead
* it goes on a trip through Xerror BadRequest and
* eventually hangs the applet
*/
public class overpaint extends Applet {
int count = 0;
String s = "supercalifragilisticexpealidocious";
String t;
public void init() {
setLayout(new BorderLayout());
add("North", new Button("Exit"));
}
public void start() {
// Send in a string that is a tad too big, to g.drawString
oversizedString(s);
overpaint(t);
}
public void oversizedString(String s){
int i = 0;
// Construct a string that is jjjuuusstttt too big
t = s;
try {
// Quickly build up a big string
for(i=0; i<16; i++) {
t = t.concat(t);
}
// Then push it over the edge
for(i=0; i<17; i++) {
t = t.concat("Z");
count++;
}
} catch (OutOfMemoryError e) {
System.out.println("Sorry, Charlie, out of memory when t is length " + t.length());
}
}
public void overpaint(String s){
System.out.println("Before drawString, in overpaint");
getGraphics().drawString(s,10,10);
System.out.println("After drawString, in overpaint");
}
public boolean action(Event e, Object arg) {
String label = (String)arg;
if (label.equals("Exit")){
System.exit(10);
}
return true;
}
}
overpaint.html is:
<title>overpaint</title>
<hr>
<applet code="overpaint.class" width=137 height=42>
</applet>
<hr>
<a href="overpaint.java">The source, Luke.</a>
and output I get is:
puffin% puffin% !!
appletviewer overpaint.html
status: applet loaded
status: applet initialized
Before drawString, in overpaint
After drawString, in overpaint
Xerror BadLength (poly request too large or internal Xlib length error)
Major opcode 75 (X_PolyText16)
Xerror BadRequest (invalid request code or no such operation)
Major opcode 0 (Unknown)
Xerror BadRequest (invalid request code or no such operation)
Major opcode 0 (Unknown)
(etc, for approx 3,200 such Xerrors)
argument to drawString doesn't cause the applet to hang.
overpaint.java is:
import java.lang.*;
import java.awt.*;
import java.applet.*;
/**
* Try to crash AWT by asking it to draw a huge string
*
* AWT should throw an exception, probably, but instead
* it goes on a trip through Xerror BadRequest and
* eventually hangs the applet
*/
public class overpaint extends Applet {
int count = 0;
String s = "supercalifragilisticexpealidocious";
String t;
public void init() {
setLayout(new BorderLayout());
add("North", new Button("Exit"));
}
public void start() {
// Send in a string that is a tad too big, to g.drawString
oversizedString(s);
overpaint(t);
}
public void oversizedString(String s){
int i = 0;
// Construct a string that is jjjuuusstttt too big
t = s;
try {
// Quickly build up a big string
for(i=0; i<16; i++) {
t = t.concat(t);
}
// Then push it over the edge
for(i=0; i<17; i++) {
t = t.concat("Z");
count++;
}
} catch (OutOfMemoryError e) {
System.out.println("Sorry, Charlie, out of memory when t is length " + t.length());
}
}
public void overpaint(String s){
System.out.println("Before drawString, in overpaint");
getGraphics().drawString(s,10,10);
System.out.println("After drawString, in overpaint");
}
public boolean action(Event e, Object arg) {
String label = (String)arg;
if (label.equals("Exit")){
System.exit(10);
}
return true;
}
}
overpaint.html is:
<title>overpaint</title>
<hr>
<applet code="overpaint.class" width=137 height=42>
</applet>
<hr>
<a href="overpaint.java">The source, Luke.</a>
and output I get is:
puffin% puffin% !!
appletviewer overpaint.html
status: applet loaded
status: applet initialized
Before drawString, in overpaint
After drawString, in overpaint
Xerror BadLength (poly request too large or internal Xlib length error)
Major opcode 75 (X_PolyText16)
Xerror BadRequest (invalid request code or no such operation)
Major opcode 0 (Unknown)
Xerror BadRequest (invalid request code or no such operation)
Major opcode 0 (Unknown)
(etc, for approx 3,200 such Xerrors)