Bug #5070
closedCore dump calling declare_namespace
100%
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])
Updated by Jacob smith over 2 years ago
The line xpath.declare_namespace(...)
results in a core dump.
Updated by O'Neil Delpratt over 2 years 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.
Updated by O'Neil Delpratt over 2 years 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.
Updated by O'Neil Delpratt over 2 years ago
- Status changed from New to AwaitingInfo
Updated by Jacob smith over 2 years ago
This patch fixes the issue I was seeing.
Updated by O'Neil Delpratt about 2 years ago
- Status changed from AwaitingInfo to Closed
- % Done changed from 0 to 100
- Fixed in version set to 11.1
Bug issue fixed in the SaxonC 11.1 release
Please register to edit this issue