Libxml2 version 2.10.0 or any higher versions crashes at SAX2.c
We have a Java application using libxml2 native libraries using JNI and all our regression tests are working fine with libxml2.9.14 version. After upgrading to 2.10.0 or higher versions (latest 2.11.14 version) the schema validation test crashes while executing [libxml2.so.2+0xa9b84] xmlStrEqual+0x24 hs_err_pid12906.log
Attached a test program but this is working fine testschema.c, but similar test is crashing while executing from the application. The crash is happening at the below code in SAX2.c
....
} else {
doc = ctxt->myDoc = xmlNewDoc(ctxt->version);
// the above line corrupts ctxt->myDoc->version
//printf("version: %s\n", ctxt->myDoc->version); //crash
if (doc != NULL) {
doc->properties = 0;
if (ctxt->options & XML_PARSE_OLD10)
doc->properties |= XML_DOC_OLD10;
doc->parseFlags = ctxt->options;
if (ctxt->encoding != NULL)
doc->encoding = xmlStrdup(ctxt->encoding);
else
doc->encoding = NULL;
doc->standalone = ctxt->standalone;
} else {
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument");
return;
}
if ((ctxt->dictNames) && (doc != NULL)) {
doc->dict = ctxt->dict;
xmlDictReference(doc->dict);
}
}
Then in parse.c, referring to ctxt->mydoc->verion crashes the application.
/*
* Remove locally kept entity definitions if the tree was not built
*/
if (ctxt->myDoc != NULL)
{
if(xmlStrEqual(ctxt->myDoc->version, SAX_COMPAT_MODE)) {
xmlFreeDoc(ctxt->myDoc);
ctxt->myDoc = NULL;
}
I notice that when I execute the test program directly, it goes through xmlNewDoc API of tree.c and it works fine, but when the crash happens the control doesn't come to xmlNewDoc API. Please help on how to proceed.