public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug java/17352] New: Uninitialized char variable causes erratic behavior
@ 2004-09-07 18:35 dtiller at captechventures dot com
  2004-09-07 18:40 ` [Bug java/17352] " dtiller at captechventures dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: dtiller at captechventures dot com @ 2004-09-07 18:35 UTC (permalink / raw)
  To: java-prs

I am using gcj-3.4.1 to compile crimson-1.1.3.jar to a static object file. When
I leave a particular Java char variable uninitialized, String and char
operations return garbage. If I initialize the variable with a throwaway value,
the program runs as expected.

In order to reproduce this issue:

1) Download crimson-1.1.3 source from <a
href="http://xml.apache.org/dist/crimson/crimson-1.1.3-src.tar.gz">here</a> or
download the attached copy. Use the ant build script to create crimson.jar.

2) compile it to an object file anf then static library with: 
        gcj -c -o crimson.o crimson.jar
        ar r libcrimson.a crimson.o
        ranlib libcrimson.a

3) Compile and link the test program:
        gcj -o Test Test.java -Icrimson.jar -L. -lcrimson -static --main=Test

4) Execute the program. You may have to set the environment variable
LANG="en_US" to avoid bug #13708. This run will result in an Exception
complaining about a bad XML version number.

5) Change line 848 in org.apache.crimson.parser.Parser2.java to "char c = 'X';"
and perform steps 1-4 again. This time the test program will succeed.

test.xml:
-----CUT HERE-----
<?xml version="1.0" encoding="UTF-8" ?>
<test />
-----CUT HERE-----

Test.java:
-----CUT HERE-----
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import java.io.FileInputStream;

class Test {
	public static void main(String[] args) {
		try {
			DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
			dbf.setValidating(false);
			dbf.setNamespaceAware(true);
			dbf.setCoalescing(true);
			DocumentBuilder db = dbf.newDocumentBuilder();
			FileInputStream fis = new FileInputStream("test.xml");
			db.parse(fis);
		} catch (Exception e) {
			System.err.println("Caught " + e);
			e.printStackTrace();
		}
	}
}
-----CUT HERE-----

-- 
           Summary: Uninitialized char variable causes erratic behavior
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dtiller at captechventures dot com
                CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
                    dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

end of thread, other threads:[~2006-02-26 19:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-17352-9267@http.gcc.gnu.org/bugzilla/>
2005-11-28  5:14 ` [Bug java/17352] Uninitialized char variable causes erratic behavior pinskia at gcc dot gnu dot org
2006-02-26 19:56 ` pinskia at gcc dot gnu dot org
2004-09-07 18:35 [Bug java/17352] New: " dtiller at captechventures dot com
2004-09-07 18:40 ` [Bug java/17352] " dtiller at captechventures dot com
2004-09-07 19:13 ` tromey at gcc dot gnu dot org
2004-09-08 12:25 ` dtiller at captechventures dot com
2004-09-28  0:26 ` pinskia at gcc dot gnu dot org
2004-10-29 17:37 ` pinskia at gcc dot gnu dot org

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).