Project

Profile

Help

Bug #5373

closed

Python multithreading code crashes

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

Status:
Closed
Priority:
Normal
Category:
Saxon-C Internals
Start date:
2022-03-07
Due date:
% Done:

100%

Estimated time:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Found in version:
11.2
Fixed in version:
11.3
SaxonC Languages:
SaxonC Platforms:
SaxonC Architecture:

Description

Reported by user in the following forum post: https://saxonica.plan.io/boards/4/topics/8523?page=2

The following SaxonC python example crashes:

import threading
import time

from saxonc import *

exitFlag = 0

class myThread (threading.Thread):
   def __init__(self, threadID, name, counter, xquery_processor):
      threading.Thread.__init__(self)
      self.threadID = threadID
      self.name = name
      self.counter = counter
      self.xquery_processor = xquery_processor
   def run(self):
      print ("Starting " + self.name)
      example(self.name, self.counter, 5, self.xquery_processor)
      print ("Exiting " + self.name)

def example(threadName, delay, counter, xquery_processor):
   while counter:
      if exitFlag:
         threadName.exit()
      time.sleep(delay)
      print("%s : %s" % (threadName, xquery_processor.run_query_to_string(query_text = '"Hello from SaxonC: " || current-dateTime()')))
      counter -= 1


saxon_proc = PySaxonProcessor(license = False)

# Create new threads
thread1 = myThread(1, "Thread-1", 1, saxon_proc.new_xquery_processor())
thread2 = myThread(2, "Thread-2", 2, saxon_proc.new_xquery_processor())

# Start new Threads
thread1.start()
thread2.start()
thread1.join()
thread2.join()
print ("Exiting Main Thread")

saxon_proc.release()

Crashes in linux as follows:

Starting Thread-1
Starting Thread-2

JET RUNTIME HAS DETECTED UNRECOVERABLE ERROR: system exception at 0x00007f71dca62d49
Please, contact the vendor of the application.
Core dump will be piped to "/usr/share/apport/apport %p %s %c %d %P %E"
Extra information about error is saved in the "jet_err_167047.txt" file.

Aborted (core dumped)

Related issues

Related to SaxonC - Bug #5050: java exception in multithreaded applicationClosedO'Neil Delpratt2021-07-29

Actions
Has duplicate SaxonC - Bug #4428: Multi-threading support of Python bindings Saxon-CClosedO'Neil Delpratt2020-01-14

Actions
Has duplicate SaxonC - Support #4942: How to prevent Saxon/C Python bindings from trying to start a new java VM when another is active? (JNI_CreateJavaVM() failed with result: -5)ClosedO'Neil Delpratt2021-03-18

Actions

Please register to edit this issue

Also available in: Atom PDF