Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AQXMLParser random crashes when parsing some xml documents #18

Open
vkodocha opened this issue Oct 31, 2012 · 2 comments
Open

AQXMLParser random crashes when parsing some xml documents #18

vkodocha opened this issue Oct 31, 2012 · 2 comments

Comments

@vkodocha
Copy link

We had the issue that some of the xml documents which we were parsing caused a crash on iOS 6. The fix is to add the following line to the AQXMLParser line 1141:

p->serror = __errorCallback2;

And adding the following method to the same file:

static void __errorCallback2(void *userData, xmlErrorPtr error) {

}

The main problem was that the serror field is not initialized to any thing valid so the call stack you get when it is crashing is more or less random.
Our crashes were also only happening when we were parsing on a background thread.

@bagelturf
Copy link

This is not the correct fix. The serror pointer should not be manipulated directly, only via the call to xmlSetStructuredErrorFunc. The docs also say that it must be set on every thread, so it is possible that if otehr code does not follow that rule, the XML parser is forever broken.

With the above fix in place, I have see other threads in 3rd party library code call into my code via this pointer.

My current fix is to not set the pointer and not call xmlSetStructuredErrorFunc, so errors are handled by the generic handler.

@bagelturf
Copy link

Experimentation shows that this appears to work:

p->error = __errorCallBack;
xmlSetStructuredErrorFunc(self,__structuredErrorFunc);
p->serror = NULL;

Errors are passed to the structured error handler. Omitting the last line or assigning non-NULL causes call-backs to random places in the app's code when an error is encountered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants