Bug 2063 – std.xml access violation for nested, closed tags

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2008-05-02T09:11:00Z
Last change time
2015-06-09T01:19:24Z
Assigned to
caron800
Creator
gaboonviper

Comments

Comment #0 by gaboonviper — 2008-05-02T09:11:01Z
If a closed <node/> is written inside another node, an access violation occurs in the constructor of the xml document document. works: <?xml version="1.0"?><tag/> doesn't work: <?xml version="1.0"?><something><tag/></something> this was tested using the following setup: import std.stdio; import std.file; import std.xml; void main{ string s = cast(string)std.file.read("widget2.xml"); check(s); auto doc = new Document(s); writefln(doc); } Cheers, Boyd
Comment #1 by gide — 2008-05-02T10:52:51Z
Malformed XML also access violates. E.g. ---- <?xml version="1.0"?><widget>
Comment #2 by caron800 — 2008-05-02T11:57:14Z
OK, thanks. Will look into that one. Janice On 02/05/2008, [email protected] <[email protected]> wrote: > http://d.puremagic.com/issues/show_bug.cgi?id=2063 > > Summary: std.xml access violation for nested, closed tags > Product: D > Version: 2.013 > Platform: PC > OS/Version: Windows > Status: NEW > Severity: major > Priority: P2 > Component: Phobos > AssignedTo: [email protected] > ReportedBy: [email protected] > > > If a closed <node/> is written inside another node, an access violation occurs > in the constructor of the xml document document. > > works: > <?xml version="1.0"?><tag/> > > doesn't work: > <?xml version="1.0"?><something><tag/></something> > > this was tested using the following setup: > > import std.stdio; > import std.file; > import std.xml; > > void main{ > string s = cast(string)std.file.read("widget2.xml"); > > check(s); > > auto doc = new Document(s); > > writefln(doc); > } > > Cheers, > Boyd > > > > -- > >
Comment #3 by caron800 — 2008-05-02T12:07:59Z
OK, thanks. I will definitely investigate that. Question: Is this in debug mode or release mode? If it's in a release build, it's not really a bug in std.xml, because you're not supposed to pass malformed XML to the parsing functions. (You call check() first, to make sure it's well formed). But if it's in a debug build, then it's definitely a bug in my code, because in that case, it should assert somewhere - ideally in an in contract. Janice On 02/05/2008, [email protected] <[email protected]> wrote: > http://d.puremagic.com/issues/show_bug.cgi?id=2063 > > > > > > ------- Comment #1 from [email protected] 2008-05-02 10:52 ------- > Malformed XML also access violates. > > E.g. > ---- > <?xml version="1.0"?><widget> > > > > -- > >
Comment #4 by gide — 2008-05-03T11:55:35Z
> Question: Is this in debug mode or release mode? Happens in both, the following code highlights the issue. [CODE] import std.stdio; import std.file; import std.xml; int main(){ try { string s1 = cast(string)std.file.read("widget.xml"); string s2 = q"[<?xml version="1.0"?><widget>]"; // print chars, s1 and s2 are the equal writeln(s1.length == s2.length); foreach (int i, char c; s1) { writeln(s1[i], ": ", s1[i] == s2[i]); } alias s1 testStr; // s1 Access Violation //alias s2 testStr; // As expected CheckException std.xml.check(testStr); auto doc = new std.xml.Document(testStr); writefln(doc); return 0; } catch (CheckException e) { writeln("XML: ", e.toString()); } catch (object.Exception e) { writeln("ERROR: ", e.toString()); } return 1; } [/CODE]
Comment #5 by caron800 — 2008-05-03T13:11:00Z
OK, thanks very much. Will fix. Janice On 03/05/2008, [email protected] <[email protected]> wrote: > http://d.puremagic.com/issues/show_bug.cgi?id=2063 > > > > > > > ------- Comment #4 from [email protected] 2008-05-03 11:55 ------- > > > Question: Is this in debug mode or release mode? > > Happens in both, the following code highlights the issue. > > [CODE] > import std.stdio; > import std.file; > import std.xml; > > int main(){ > try { > string s1 = cast(string)std.file.read("widget.xml"); > string s2 = q"[<?xml version="1.0"?><widget>]"; > > // print chars, s1 and s2 are the equal > writeln(s1.length == s2.length); > foreach (int i, char c; s1) { > writeln(s1[i], ": ", s1[i] == s2[i]); > } > > alias s1 testStr; // s1 Access Violation > //alias s2 testStr; // As expected CheckException > std.xml.check(testStr); > auto doc = new std.xml.Document(testStr); > writefln(doc); > > return 0; > } catch (CheckException e) { > writeln("XML: ", e.toString()); > } catch (object.Exception e) { > writeln("ERROR: ", e.toString()); > } > return 1; > } > [/CODE] > > > > -- > >
Comment #6 by bugzilla — 2008-05-22T05:03:00Z
Fixed dmd 2.014