Project

Profile

Help

Bug #4351

closed

set_parameter failing under PyXPathProcessor

Added by O'Neil Delpratt over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Category:
Python
Start date:
2019-10-19
Due date:
% Done:

100%

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

Description

Reported by user in the forum post:

https://saxonica.plan.io/boards/4/topics/7621

Python script:

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.


Related issues

Related to SaxonC - Bug #4356: XPathProcessor missing methodsClosedO'Neil Delpratt2019-10-22

Actions
Actions #1

Updated by O'Neil Delpratt over 4 years 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.

Actions #2

Updated by Michael Kay over 4 years ago

I guess there's a workaround of using the XQuery API instead?

Actions #3

Updated by O'Neil Delpratt over 4 years ago

Yes indeed the workaround would be to use the XQuery API.

Actions #4

Updated by O'Neil Delpratt over 4 years ago

  • Description updated (diff)
Actions #5

Updated by O'Neil Delpratt over 4 years ago

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.

Actions #6

Updated by O'Neil Delpratt over 4 years ago

  • Related to Bug #4356: XPathProcessor missing methods added
Actions #7

Updated by O'Neil Delpratt over 4 years 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.

Actions #8

Updated by O'Neil Delpratt over 4 years ago

  • Status changed from Resolved to Closed
  • Fixed in version set to 1.2.1

Bug fix applied in the Saxon/C maintenance release 1.2.1

Please register to edit this issue

Also available in: Atom PDF