Menu

#3 Parser seems to recurse when it shouldn't.

open
nobody
None
5
2010-04-07
2010-04-07
Tom Evans
No

The first comment on this forum stated that parsing a big file ran the computer out of memory.
I may have found why this is happening.
A "recursive parser" is usually meant to "stay at the same level" when parsing tags at the same level,
but then recurse DOWN for parsing children of a node. When finished with the childred it
is meant to return UP. So the maximum recursion depth should be the same as the maximum
tree depth (give or take).

Here's an edited version of the stack dump (just before it crashed) of picoXML parsing a
bunch of tags with attributes, some of which are shown in the "buf" parameter on the
first level:

(gdb) where
#0 parseNode (
buf=0xac2b20 "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<EDIFactoryConf
ig Version=\"1\">\r\n\t<VIN Digits2to17=\"", 'a' <repeats 16 times>, "\" />\r\n\ t<Build Number=\"9999\" />\r\n\t<Model Name=\"ModelName\" Type=\"Normal\" Yea
r=\"10.6\" />\r\n\t<"..., curr=0x22cbc0, node=0xab31a8) at picoXML.c:611
#1 0x00401d92 in parseNode (
#2 0x004019aa in parseContent (
#3 0x00401c81 in parseNode (
#4 0x004019aa in parseContent (
#5 0x00401c81 in parseNode (
#6 0x00401d92 in parseNode (
#7 0x00401d92 in parseNode (
#8 0x00401d92 in parseNode (
#9 0x00401d92 in parseNode (
#10 0x00401d92 in parseNode (
#11 0x00401d92 in parseNode (
#12 0x00401d92 in parseNode (
#13 0x00401d92 in parseNode (
#14 0x00401d92 in parseNode (
#15 0x00401d92 in parseNode (
#16 0x004019aa in parseContent (
#17 0x00401c81 in parseNode (
#18 0x004020bb in picoCreateFromBuf (doc=0x22cbf4,
#19 0x004023b6 in testParse (a_pFactory=0x405030,
#20 0x00402983 in main (argc=2, argv=0xab28d0) at Test.c:59

It is calling parseNode() for every new node! I don't think that is intentional.
It shouldn't be necessary.

I've got some nodes with sub-nodes and when it tries to parse that it
corrupts the stack and crashes trying to come back "UP".

I don't know how to fix this. I'm going to use another parser instead.

Discussion


Log in to post a comment.