set_parameter failing under PyXPathProcessor
Reported by user in the forum post:
import saxonc s1 = 'This is a test.' with saxonc.PySaxonProcessor(license=False) as proc: print(proc.version) xdm_string_value = proc.make_string_value(s1) print(xdm_string_value) xpath_processor = proc.new_xpath_processor() xpath_processor.set_parameter('s1', xdm_string_value) result = xpath_processor.evaluate('$s1') print(result) print(result.get_atomic_value().string_value)
I ran the same sample python script under linux with gdb command:
Thread 1 "python3" received signal SIGSEGV, Segmentation fault. 0x00007ffff005117d in ?? () from /usr/lib//libsaxoneec.so (gdb) bt #0 0x00007ffff005117d in ?? () from /usr/lib//libsaxoneec.so #1 0x00007ffaf5906341 in ?? () #2 0x00007ffaf5906341 in ?? () #3 0x00007ffff69c4308 in SaxonProcessor::refCount () from /home/ond1/work/svn/latest9.9-saxonc/Saxon.C.API/python-saxon/saxonc.cpython-35m-x86_64-linux-gnu.so #4 0x00007ffff6799490 in JNIEnv_::GetArrayLength (array=0x0, this=<optimised out>) at ../jni/jni.h:1624 #5 XPathProcessor::evaluate (this=0x1150d30, xpathStr=0x7ffff7eab8c0 "$s1") at ../XPathProcessor.cpp:92 #6 0x00007ffff675614e in __pyx_pf_6saxonc_16PyXPathProcessor_6evaluate (__pyx_v_self=<optimised out>, __pyx_v_xpath_str=<optimised out>) at saxonc.cpp:25091 #7 __pyx_pw_6saxonc_16PyXPathProcessor_7evaluate (__pyx_v_self=<optimised out>, __pyx_v_xpath_str=<optimised out>) at saxonc.cpp:25007 #8 0x000000000053b486 in PyEval_EvalFrameEx () #9 0x000000000053fc97 in ?? () #10 0x00000000005409bf in PyEval_EvalCode () #11 0x000000000060cb42 in ?? () #12 0x000000000060efea in PyRun_FileExFlags () #13 0x000000000060f7dc in PyRun_SimpleFileExFlags () #14 0x0000000000640256 in Py_Main () #15 0x00000000004d0001 in main ()
There seems to be a memory handling issue. Investigating now.
#1 Updated by O'Neil Delpratt 11 months ago
Exception thrown early in code:
net.sf.saxon.s9api.SaxonApiException : Undeclared variable in XPath expression: $s1
The cause of the problem is the XPathProcessor API for C++, Python and PHP does not have any way to declare variables. The Java class
XPathCompiler has the declareVariable method. There is no real workaround for this issue. A fix will be in the next maintenance release.
#7 Updated by O'Neil Delpratt 11 months ago
- Status changed from In Progress to Resolved
- % Done changed from 0 to 100
O'Neil Delpratt wrote:
I have added now added the method
declareVariable(const char * clarkName)to the C++ class XPathProcessor. Equivalent wrapper functions are also required in the PHP and Python APIs.
As mentioned in the bug issue #4356 we have decided to revert the addition of the method
declareVariable, instead we now allow undeclared variables in the XPathProcessor, which simplifies the API for the user.
Bug fix available in the next maintenance release.
Please register to edit this issue