|
|
Home » U++ Library support » U++ Core » ParseXML intermittent crash
ParseXML intermittent crash [message #35656] |
Sun, 11 March 2012 01:25 |
nixnixnix
Messages: 415 Registered: February 2007 Location: Kelowna, British Columbia
|
Senior Member |
|
|
I am trying to use ParseXML to well parse some XML. I find that most of the time it works fine but sometimes it eats up 2GB of RAM and then crashes out with out of memory.
When I try to debug it this never happens. Only when I build as optimal or speed not debug.
Does anybody else get this? I find that especially when I try to parse several files one after the other it almost always crashes but again not in debug mode.
I've commented out all my code and it is definitely ParseXML which is doing something bad. I suspect it is something to do with the recursive structure of XML. It would be good if I could tell it to only go to so many levels. That way, I could try it once and if it fails start over and try again.
I use the same 7 XML files every time and get different results.
Any ideas as to what I could try to hunt down the cause?
Nick
EDIT: I have anonymised my data files and I still get the crash. Here is the package and the data files which crash it. I am pretty sure it is infinite recursion but I don't understand exactly what sReadXmlNode() is doing as I don't really get the whole Node/Tag/PI distinction.
If you drag and drop the files in individually there is no problem usually However, if you grab them all or sometimes just a couple of them it will usually crash. Sometimes just dragging and dropping one file causes the crash.
Update: even weirder. Reordering the files in windows by type determines whether or not the crash happens. WTF!?!
[Updated on: Wed, 14 March 2012 01:46] Report message to a moderator
|
|
|
|
Re: ParseXML intermittent crash [message #35817 is a reply to message #35806] |
Fri, 23 March 2012 15:04 |
Sender Ghost
Messages: 301 Registered: November 2008
|
Senior Member |
|
|
Hello, Nick.
nixnixnix wrote on Fri, 23 March 2012 01:59 | Anyone manage to recreate the crash at least?
|
Yes, if throwing many XML files, one after one.
I think, this is synchronization problems.
To check this, just replace following source code for WRA\main.cpp file (from 321 line):
void Wrap::OpenTowerXML(String path)
{
FileIn iFile(path);
if(!iFile.IsOpen())
{
PromptOK("failed to open file");
return;
}
// int k = int(iFile.GetSize());
int64 k = iFile.GetLeft();
char* pBuf = new char[k];
if(!iFile.GetAll(pBuf,k))
{
iFile.Close();
delete[] pBuf;
return;
}
iFile.Close();
String xml(pBuf);
XmlNode xn = ParseXML(xml);
To:
void Wrap::OpenTowerXML(String path)
{
GuiLock __;
XmlNode xn;
{
String xml(LoadFile(path));
if (xml.IsVoid())
{
PromptOK(Format("Failed to open '\1%s' file", path));
return;
}
try {
xn = ParseXML(xml);
}
catch (XmlError e) {
PromptOK(Format("XmlError for '%s' file:&%s", DeQtf(path), DeQtf(e)));
return;
}
}
And remove further source codes from the same Wrap::OpenTowerXML function (424, 428 lines):
Or use changed file from attached archive.
[Updated on: Fri, 23 March 2012 15:26] Report message to a moderator
|
|
|
|
Re: ParseXML intermittent crash [message #35820 is a reply to message #35818] |
Fri, 23 March 2012 21:45 |
Sender Ghost
Messages: 301 Registered: November 2008
|
Senior Member |
|
|
nixnixnix wrote on Fri, 23 March 2012 19:28 | Yes that appears to have fixed it. I am not using multithreading so I didn't think I had to worry about things not happening in order.
|
After building with GUI configuration, I found, that real cause is correlation between pBuf dynamic array and ParseXML function. With String variable and LoadFile function it's ok.
Edit:
The XmlParser expects zero terminated characters. Therefore, changing following source code (from line 332):
int64 k = iFile.GetLeft();
char* pBuf = new char[k];
To:
int64 k = iFile.GetLeft();
char* pBuf = new char[k + 1];
pBuf[k] = '\0';
Will solve this issue.
[Updated on: Fri, 23 March 2012 23:03] Report message to a moderator
|
|
|
|
Re: ParseXML intermittent crash [message #35822 is a reply to message #35821] |
Fri, 23 March 2012 23:34 |
Sender Ghost
Messages: 301 Registered: November 2008
|
Senior Member |
|
|
Well, I also did some mistakes with approaching the problem.
I did it by fixing the cause and what surrounded it at once, instead of much precise analyzing and iterative fixing. Therefore, some my guesses were wrong (about multithreading).
Don't worry. Glad, it helps.
[Updated on: Fri, 23 March 2012 23:35] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sat Sep 21 01:46:47 CEST 2024
Total time taken to generate the page: 0.03587 seconds
|
|
|