Project

Profile

Help

Bug #5070

Core dump calling declare_namespace

Added by Jacob smith about 2 months ago. Updated about 2 months ago.

Status:
AwaitingInfo
Priority:
High
Category:
Python
Start date:
2021-08-27
Due date:
% Done:

0%

Estimated time:
Found in version:
1.2.1
Fixed in version:
Platforms:

Description

My environment is a homebrew Python3 (3.9); I installed Cython (not sure of the version), and built as per the instructions.

The version of Saxon/C is 1.2.1 HE and/or EE.

#!/usr/bin/env python3

import os
import sys

cnlDir                      = os.path.dirname(os.path.realpath(__file__))
SAXONC_HOME                 = os.path.abspath(cnlDir + '/../tools/saxonc')
SAXONC_PYHOME               = SAXONC_HOME + '/Saxon.C.API/python-saxon/'

sys.path.append(SAXONC_PYHOME)
os.environ['SAXONC_HOME']   = SAXONC_HOME

import saxonc

if __name__ == '__main__':
    xdocPath        = os.path.abspath(os.path.expanduser(sys.argv[1]))

    with saxonc.PySaxonProcessor() as saxp:
        xpath       = saxp.new_xpath_processor()
        xpath.declare_namespace('uncle', 'http://apple.com/ns/bob/uncle')
        xdoc        = saxp.parse_xml(xml_file_name=xdocPath)
        xpath.set_context(xdm_item=xdoc)
        results     = xpath.evaluate('.//*:decTree[@spec]')
        print(f'Num results: {results.size}')
        for II in range(results.size):
            repr    = str(results.item_at(II).get_node_value())
            print(repr.split('\n')[0])

History

#1 Updated by Jacob smith about 2 months ago

The line xpath.declare_namespace(...) results in a core dump.

#2 Updated by O'Neil Delpratt about 2 months ago

  • Category set to Python
  • Assignee set to O'Neil Delpratt

Thanks for reporting the problem you have found. This does look like the problem that was reported #4513. But to investigate the underlying problem if you are running this python script from the linux command-line is it possible you can run the command with gdb. For example:

gdb python3
handle SIG35 noprint nostop
run script.py

Replace script.py with the name of your file. Please send us the error.

#3 Updated by O'Neil Delpratt about 2 months ago

Hi,

There is a bug in the XPathProcessor.cpp file in the declareNamespace method. It has incorrect method signature in the JNI. See line 254:

		(jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(cppClass, "declareNamespace",
				"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");

Replace with the following code:

		(jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(cppClass, "declareNamespace",
				"(Ljava/lang/String;Ljava/lang/String;)V");

Then rebuild the python library.

This is what was mentioned in the forum post: https://saxonica.plan.io/boards/3/topics/7804

I ran a similar code logic to you and it works for me after I applied the fix.

#4 Updated by O'Neil Delpratt about 2 months ago

  • Status changed from New to AwaitingInfo

#5 Updated by Jacob smith about 2 months ago

This patch fixes the issue I was seeing.

Please register to edit this issue

Also available in: Atom PDF