Actions
Bug #5787
closedmuitithreading example with preview of SaxonC 12: Fatal error: StackOverflowError: Enabling the yellow zone of the stack did not make any stack space available
Start date:
2023-01-03
Due date:
% Done:
100%
Estimated time:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Found in version:
12.0
Fixed in version:
12.1
SaxonC Languages:
SaxonC Platforms:
SaxonC Architecture:
Description
User reported crash here: https://saxonica.plan.io/boards/4/topics/9158 and https://saxonica.plan.io/boards/4/topics/9160
SaxonC 11.99 crashes with the following error:
muitithreading example with preview of SaxonC 12: Fatal error: StackOverflowError: Enabling the yellow zone of the stack did not make any stack space available
The failures happen under flask, but will try to reproduce it outside of flask. See example code below:
from flask import Flask
from flask import g
from saxonc import *
def get_saxon():
if 'saxon' not in g:
g.saxon = PySaxonProcessor(license = False)
return g.saxon
app = Flask(__name__)
@app.route('/')
def hello_world(): # put application's code here
return 'Hello World!'
@app.route('/saxontest2')
def saxontest2():
"""Returns result from Saxon XQuery evaluation"""
return get_saxon().new_xquery_processor().run_query_to_string(query_text = '"Hello from Saxon: " || current-dateTime()')
@app.teardown_appcontext
def teardown_saxonc_thread(exception):
saxon = g.pop('saxon', None)
if saxon is not None:
saxon.detach_current_thread
if __name__ == '__main__':
app.run()
Another example code which does not require flask:
import threading
import time
from saxonc import *
exitFlag = 0
class myThread(threading.Thread):
def __init__(self, threadID, name, counter, proc, xquery_processor):
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
self.counter = counter
self.xquery_processor = xquery_processor
self.proc = proc
def run(self):
print("Starting " + self.name)
example(self.name, self.counter, 5, self.proc, self.xquery_processor)
print("Exiting " + self.name)
def example(threadName, delay, counter, proc, xquery_processor):
while counter > 0:
if exitFlag:
threadName.exit()
time.sleep(delay)
result = xquery_processor.run_query_to_string(query_text='"Hello from SaxonC: " || current-dateTime()')
if result is None:
threadName.exit()
print("%s : %s" % (threadName, result))
counter -= 1
proc.detach_current_thread
def example2(threadName, delay, counter, xquery_processor):
while counter > 0:
if exitFlag:
return
time.sleep(delay)
result = xquery_processor.run_query_to_string(query_text='"Hello from SaxonC: " || current-dateTime()')
if result is None:
return
print("%s : %s" % (threadName, result))
counter -= 1
saxon_proc = PySaxonProcessor(license=False)
# Create new threads
thread1 = myThread(1, "Thread-1", 1, saxon_proc, saxon_proc.new_xquery_processor())
thread2 = myThread(2, "Thread-2", 2, saxon_proc, saxon_proc.new_xquery_processor())
# Start new Threads
thread1.start()
thread2.start()
thread1.join()
thread2.join()
print("Exiting Main Thread")
Please register to edit this issue
Actions