https://saxonica.plan.io/https://saxonica.plan.io/favicon.ico2021-01-28T17:28:04ZSaxonica Developer CommunitySaxonC - Bug #4885: Exception 0xC0000005 (EXCEPTION_ACCESS_VIOLATION) Failed to read memory at 0x0000000000000000https://saxonica.plan.io/issues/4885?journal_id=171552021-01-28T17:28:04ZO'Neil Delprattoneil@saxonica.com
<ul><li><strong>Category</strong> set to <i>Python</i></li><li><strong>Assignee</strong> set to <i>O'Neil Delpratt</i></li><li><strong>Found in version</strong> set to <i>1.2.1</i></li></ul><p>Hi,</p>
<p>Please can you send me privately your XSLT file so that I can try and reproduce the error.</p> SaxonC - Bug #4885: Exception 0xC0000005 (EXCEPTION_ACCESS_VIOLATION) Failed to read memory at 0x0000000000000000https://saxonica.plan.io/issues/4885?journal_id=171592021-01-29T16:58:36ZO'Neil Delprattoneil@saxonica.com
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>In Progress</i></li></ul><p>Hi Brian,</p>
<p>I have managed to reproduce the issue you reported. I see the following printout then it hangs and then crashes:</p>
<pre><code>Test Saxon/C on Python
Saxon/C 1.2.1 running with Saxon-HE 9.9.1.5C from Saxonica
AccountTransfer-runtime-compiled.xsl
nc:Date is required in ns2:StartDate.
</code></pre>
<p>I am not seeing the problem on Java, so it is specific to Saxon/C. I am still investigating.</p> SaxonC - Bug #4885: Exception 0xC0000005 (EXCEPTION_ACCESS_VIOLATION) Failed to read memory at 0x0000000000000000https://saxonica.plan.io/issues/4885?journal_id=171622021-02-01T14:48:24ZO'Neil Delprattoneil@saxonica.com
<ul></ul><p>Update:</p>
<p>On Saxon/C the stylesheet with the given source documents works fine using the command Transfom.c and within the C++ API. Therefore the bug is specific to the python API.</p> SaxonC - Bug #4885: Exception 0xC0000005 (EXCEPTION_ACCESS_VIOLATION) Failed to read memory at 0x0000000000000000https://saxonica.plan.io/issues/4885?journal_id=171632021-02-01T20:58:27ZO'Neil Delprattoneil@saxonica.com
<ul><li><strong>Status</strong> changed from <i>In Progress</i> to <i>Rejected</i></li></ul><p>Hi Brian,</p>
<p>Having looked back at the python code. These are the problems I found:</p>
<ol>
<li>The program runs out of memory due to the while loop going into infinite loop. The <code>i</code> variable needs incrementing.</li>
<li>PySaxonProcessor objects is created within <code>for</code> loop, which is not advised as it should in most cases created once.</li>
</ol> SaxonC - Bug #4885: Exception 0xC0000005 (EXCEPTION_ACCESS_VIOLATION) Failed to read memory at 0x0000000000000000https://saxonica.plan.io/issues/4885?journal_id=171682021-02-02T23:25:10ZO'Neil Delprattoneil@saxonica.com
<ul><li><strong>Status</strong> changed from <i>Rejected</i> to <i>In Progress</i></li></ul><p>I am reopening this bug issue because after fixing up the python code with the suggestions in comment #4 the user is now getting a segmentation error.</p>
<p>This looks like a bug. The problem is if there are no XSL messages the variable <code>msg</code> in the code <code>msg=xslt30_processor.get_xsl_messages()</code> should be <code>None</code>, but it is in a unclean state.</p> SaxonC - Bug #4885: Exception 0xC0000005 (EXCEPTION_ACCESS_VIOLATION) Failed to read memory at 0x0000000000000000https://saxonica.plan.io/issues/4885?journal_id=171692021-02-03T01:07:24ZO'Neil Delprattoneil@saxonica.com
<ul></ul><p>This is indeed a bug. In the saxonc.pyx file the following patch should be applied to the get_xsl_messages method which appears in the classes <code>PyXsltProcessor</code> and <code>PyXslt30Processor</code>:</p>
<pre><code class="python syntaxhl" data-language="python"> <span class="k">def</span> <span class="nf">get_xsl_messages</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="s">"""
Get the messages written using the <code>xsl:message</code> instruction
get_xsl_message(self)
Returns:
PyXdmValue: Messages returned as an XdmValue.
"""</span>
<span class="n">cdef</span> <span class="n">saxoncClasses</span><span class="p">.</span><span class="n">XdmValue</span> <span class="o">*</span> <span class="n">xdmValue</span> <span class="o">=</span> <span class="n">NULL</span>
<span class="n">cdef</span> <span class="n">PyXdmValue</span> <span class="n">val</span> <span class="o">=</span> <span class="bp">None</span>
<span class="n">xdmValue</span> <span class="o">=</span> <span class="bp">self</span><span class="p">.</span><span class="n">thisxptr</span><span class="p">.</span><span class="n">getXslMessages</span><span class="p">()</span>
<span class="k">if</span> <span class="n">xdmValue</span> <span class="ow">is</span> <span class="n">NULL</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">None</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">val</span> <span class="o">=</span> <span class="n">PyXdmValue</span><span class="p">()</span>
<span class="n">val</span><span class="p">.</span><span class="n">thisvptr</span> <span class="o">=</span> <span class="n">xdmValue</span>
<span class="k">return</span> <span class="n">val</span>
</code></pre>
<p>Also at the end of the users python script the <code>proc.release()</code> method is required.</p>
<p>Alternatively, if the <code>PySaxonProcessor</code> is used as a context then itself calls the <code>release</code> method:</p>
<pre><code class="python syntaxhl" data-language="python"><span class="k">with</span> <span class="n">saxonc</span><span class="p">.</span><span class="n">PySaxonProcessor</span><span class="p">(</span><span class="n">license</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span> <span class="k">as</span> <span class="n">proc</span><span class="p">:</span>
<span class="p">......</span>
</code></pre> SaxonC - Bug #4885: Exception 0xC0000005 (EXCEPTION_ACCESS_VIOLATION) Failed to read memory at 0x0000000000000000https://saxonica.plan.io/issues/4885?journal_id=173612021-02-15T13:07:51ZO'Neil Delprattoneil@saxonica.com
<ul><li><strong>File</strong> <a href="/attachments/49220">saxonc.pyx</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/49220/saxonc.pyx">saxonc.pyx</a> added</li><li><strong>Status</strong> changed from <i>In Progress</i> to <i>Resolved</i></li></ul><p>I am closing this bug as the fix was described in comment #6. Also added the patched file to this bug issue.</p>
<p>The mechanism for Saxon/C 1.3 has changed. We will be delivering the xsl:messages to return them in a filename given by the user.</p> SaxonC - Bug #4885: Exception 0xC0000005 (EXCEPTION_ACCESS_VIOLATION) Failed to read memory at 0x0000000000000000https://saxonica.plan.io/issues/4885?journal_id=191942022-02-01T15:43:29ZO'Neil Delprattoneil@saxonica.com
<ul><li><strong>Status</strong> changed from <i>Resolved</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li><li><strong>Fixed in version</strong> set to <i>11.1</i></li></ul><p>Bug fix patched in SaxonC 11.1 release</p>