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 Arnaud Le Hors <le...@us.ibm.com> on 2000/12/21 00:34:27 UTC

Infinite loop

David (Parker),
we've discovered that the change I made last week to address the
infinite loop you reported when parsing an empty input file introduced
another bug. So I had to undo the change. That means the problem you
were facing is back in. I'd like to look for a better fix but for that I
need to be able to reproduce the bug. As I said last week, feeding the
parser with an empty file doesn't do. Please advise.
Thank you.
-- 
Arnaud  Le Hors - IBM Cupertino, XML Technology Group

Re: Infinite loop

Posted by Arnaud Le Hors <le...@us.ibm.com>.
David,
I know for sure that I changed XMLDocumentScanner back to what it was,
that is PrologDispatcher.dispatch() returns true, and I don't get any
infinite loop. So, try again with the latest from CVS and let me know if
you can reproduce the problem and exactly how.
Thank you.
-- 
Arnaud  Le Hors - IBM Cupertino, XML Technology Group

RE: Infinite loop

Posted by David Parker <dp...@ebt.com>.
Are you sure that you have backed out the change in the PrologDispatcher
code? The behavior was, for an empty InputSource, that the fDispatcher
variable never got re-set, and the code fell through the loop and always
returned true from the dispatch() method. I know I didn't imagine this
behavior, because I stepped through it in the debugger for many iterations
before I realized that the fDispatcher variable was supposed to be getting
changed.

- DAP

> -----Original Message-----
> From: Arnaud Le Hors [mailto:lehors@us.ibm.com]
> Sent: Thursday, December 21, 2000 1:46 PM
> To: xerces-j-dev@xml.apache.org
> Subject: Re: Infinite loop
>
>
> David Parker wrote:
> >
> > Really? Sorry about that. What was the other bug? We have been
> doing a lot
> > of parsing with that fix in....
>
> The EndOfInput dispatcher and therefore the endDocument callback gets
> never called.
>
> > Sorry for rambling. Anyway, I have attached the slightly modified
> > SAXCount.java that I used in reproducing the bug. I guess I
> missed that you
> > had never actually been able to repro it. Again, sorry for any
> confusion I
> > may have caused.
>
> I just tried it with an empty file. Same thing. It doesn't cause any
> problem. I get the following expected error:
>
> [Fatal Error] :1:1: The root element is required in a well-formed
> document.
> org.xml.sax.SAXException: Stopping after fatal error: The root element
> is
> required in a well-formed document.
> --
> Arnaud  Le Hors - IBM Cupertino, XML Technology Group
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: Infinite loop

Posted by Arnaud Le Hors <le...@us.ibm.com>.
David Parker wrote:
> 
> Really? Sorry about that. What was the other bug? We have been doing a lot
> of parsing with that fix in....

The EndOfInput dispatcher and therefore the endDocument callback gets
never called.

> Sorry for rambling. Anyway, I have attached the slightly modified
> SAXCount.java that I used in reproducing the bug. I guess I missed that you
> had never actually been able to repro it. Again, sorry for any confusion I
> may have caused.

I just tried it with an empty file. Same thing. It doesn't cause any
problem. I get the following expected error:

[Fatal Error] :1:1: The root element is required in a well-formed
document.
org.xml.sax.SAXException: Stopping after fatal error: The root element
is
required in a well-formed document.
-- 
Arnaud  Le Hors - IBM Cupertino, XML Technology Group

RE: Infinite loop

Posted by David Parker <dp...@ebt.com>.
Really? Sorry about that. What was the other bug? We have been doing a lot
of parsing with that fix in....

I can't get to my other emails at the moment, and I can't remember exactly
what the test case was, but I believe it might require creating your
InputSource from a FileReader on an empty file.

The only reason I am unclear on this is that creating an InputSource from a
Reader is the source for another bug I ran into, where the InputSource
SystemID is null. When you have an external entity decl in your file,
DefaultEntityHandler.addExternalEntityDecl() passes a null fSystemId (it
populates this with a call to InputSource) to StringPool.addSymbol(), which
in turn calls length() without checking for null.

I fixed this locally by adding a check in addSymbol() for null input and
returning -1 if so. Don't know if that's right, but it seems to work.

Sorry for rambling. Anyway, I have attached the slightly modified
SAXCount.java that I used in reproducing the bug. I guess I missed that you
had never actually been able to repro it. Again, sorry for any confusion I
may have caused.

- DAP

> -----Original Message-----
> From: Arnaud Le Hors [mailto:lehors@us.ibm.com]
> Sent: Wednesday, December 20, 2000 5:34 PM
> To: xerces-j-dev@xml.apache.org
> Subject: Infinite loop
>
>
> David (Parker),
> we've discovered that the change I made last week to address the
> infinite loop you reported when parsing an empty input file introduced
> another bug. So I had to undo the change. That means the problem you
> were facing is back in. I'd like to look for a better fix but for that I
> need to be able to reproduce the bug. As I said last week, feeding the
> parser with an empty file doesn't do. Please advise.
> Thank you.
> --
> Arnaud  Le Hors - IBM Cupertino, XML Technology Group
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org