LibXML2 issue
Posted: Thu Mar 28, 2024 11:24 am
This issue exists on HPE I64 C Compiler and VSI x86 C Compiler. I have to assume its actually working as intended and my limited C skills are not really up to the task, hence the reason I am hoping someone with OpenVMS C knowledge has the answer.
We use LibXML2 to parse XML and build the DOM tree so we can extract values. When we get malformed XML data, LIBXML2 will attempt to write the error to the xmlLastError variable declared in globals.c The definition of xmlLastError is straight forward. Its just
xml1Error xmLastError; //just a typical type and variable name declaration
xmlLastError is never written to in globals.c The only reference to it is via a routine that will pass back the address of the variable. When an error is detected in the XML data, the parsing logic gets the address for xmlLastError and attempts to write the error to it. Since xmlLastError has been declared by either the compiler or linker to be Read Only, this results in an access violation which is not an elegant way to handle malformed XML data.
Currently to get around this issue, I have been altering the opensource globals.,c code to be:
xmlError xmlLastError = {0};
I am assuming the compiler/linker is optimizing something and thinking to itself, this variable is never written to so I can just park it into read only land and the initialization stops that.
Is there a compiler switch/setting or some other way to force the compiler/linker to not place the variable into the programs read only section? Is there any proper way to tell the compiler/linker that this variable is not read only, ie maybe in the link .opt file or something. I would like to not change the open source code but instead just alter our local build code for the package.
Rod Prince
We use LibXML2 to parse XML and build the DOM tree so we can extract values. When we get malformed XML data, LIBXML2 will attempt to write the error to the xmlLastError variable declared in globals.c The definition of xmlLastError is straight forward. Its just
xml1Error xmLastError; //just a typical type and variable name declaration
xmlLastError is never written to in globals.c The only reference to it is via a routine that will pass back the address of the variable. When an error is detected in the XML data, the parsing logic gets the address for xmlLastError and attempts to write the error to it. Since xmlLastError has been declared by either the compiler or linker to be Read Only, this results in an access violation which is not an elegant way to handle malformed XML data.
Currently to get around this issue, I have been altering the opensource globals.,c code to be:
xmlError xmlLastError = {0};
I am assuming the compiler/linker is optimizing something and thinking to itself, this variable is never written to so I can just park it into read only land and the initialization stops that.
Is there a compiler switch/setting or some other way to force the compiler/linker to not place the variable into the programs read only section? Is there any proper way to tell the compiler/linker that this variable is not read only, ie maybe in the link .opt file or something. I would like to not change the open source code but instead just alter our local build code for the package.
Rod Prince