You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by David Corbin <da...@machturtle.com> on 2001/01/11 20:40:02 UTC

Multi-threading bug?

I believe I've "found" a multi-threading bug in Xerces.  After much
narrowing down I've produced the test code below.  

--cut--
import org.apache.xerces.parsers.*;
 
public class XTest
{
        public static void main(String[] args)
        {
		int count=10;
                for (int x=0; x<count; x++)
                {
                        Thread thread = new Thread() {
                                public void run()
                                {
                                        try
                                        {
                                                for (int i=0; i<40; i++)
                                                {
                                                       
System.out.print("*");
                                                        new DOMParser();
                                                }
                                        }
                                        catch(Exception e)
                                        {
                                                e.printStackTrace();
                                        }
                                        System.out.println("!");
                                }
                        };
                        thread.start();
                }
        }
}
--cut--

When I run this code with count=1, it works great.  When I run it with
count = 10, it usually creates a problem.  In 1.2.1, the problem is
usually a NullPointerException with a stack trace that looks like
this....

java.lang.NullPointerException
	at
org.apache.xerces.validators.common.XMLValidator.init(XMLValidator.java:1535)
	at
org.apache.xerces.validators.common.XMLValidator.<init>(XMLValidator.java:401)
	at org.apache.xerces.framework.XMLParser.<init>(XMLParser.java:203)
	at org.apache.xerces.parsers.DOMParser.<init>(DOMParser.java:214)
	at XTest$1.run(XTest.java:17)

Sometimes, the exact line of the exception moves a line or two.

If I use 1.2.3, when the problem manifests itself, I don't ususally get
an exception, the program just hangs.

And, if I run it in my debugger (JBuilder 4 Foundation), the problem
generally doesn't happen.

FWIW, I'm running on Linux with JDK 1.3.

I'm attempting to locate the exact problem, but I've never looked at the
Xerces code before this. (I've been using it for a while.  thanks
everyone).   I'm posting this now because I thought someone more
familiar with it might be able to find a fix faster.

Questions?
-- 
David Corbin 		
Mach Turtle Technologies, Inc.
http://www.machturtle.com
dcorbin@machturtle.com