How to debug XML parsing failures

This article explains how to troubleshoot XML parsing errors.

Details

Solver failures that include messages such as:

Expat Error (0): cannot parse buffer
forrtl: severe (174): SIGSEGV, segmentation fault occurred

often indicate that an XML file used by the solver cannot be properly parsed.

These errors are not always caused by a single obvious issue. Instead, they typically result from problems in how the XML file is generated, written, or interpreted on the system.

Start by verifying that the XML file is syntactically well-formed. Run the following bash command in the directory where the XML file is located:

xmllint --noout your_file_name.xml
  • If the file is valid, the command returns no output.
  • If invalid, it reports the exact line and column where parsing fails.

This can quickly help identify issues such as malformed tags, invalid entities, unexpected or unsupported characters, or structural corruption.

Note that this check only confirms whether the XML is syntactically well-formed. It does not detect:

  • Characters that are valid UTF-8 but still cause problems for NX2TMG’s internal parser.
  • Semantic issues where the XML structure is well-formed but does not match what NX2TMG expects.