Skip to content

Commit a1e5d2e

Browse files
committed
refs qore/issues#4651 fixed a crash in at_exit handlers when initialized from Java
refs qore/issues#4652 fixed a memory leak with subinterpreters when initialized by Python though the qoreloader module
1 parent f625e84 commit a1e5d2e

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ project(qore-python-module)
33

44
set (VERSION_MAJOR 1)
55
set (VERSION_MINOR 1)
6-
set (VERSION_PATCH 5)
6+
set (VERSION_PATCH 6)
77

88
set(PROJECT_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
99

docs/mainpage.dox.tmpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,13 @@ PythonProgram::setSaveObjectCallback(callback);
500500
501501
@section pythonreleasenotes python Module Release Notes
502502
503+
@subsection python_1_1_6 python Module Version 1.1.6
504+
- fixed a memory leak with subinterpreters when the module is initialized by python through the
505+
@ref python_qoreloader_module "qoreloader" module
506+
(<a href="https://github.com/qorelanguage/qore/issues/4652">issue 4652</a>)
507+
- fixed a crash on exit when %Qore and the python module were initialized from Java
508+
(<a href="https://github.com/qorelanguage/qore/issues/4651">issue 4651</a>)
509+
503510
@subsection python_1_1_5 python Module Version 1.1.5
504511
- updated to support Python 3.11
505512
(<a href="https://github.com/qorelanguage/qore/issues/4650">issue 4650</a>)

qore-python-module.spec

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
%global user_module_dir %{mydatarootdir}/qore-modules/
66

77
Name: qore-python-module
8-
Version: 1.1.5
8+
Version: 1.1.6
99
Release: 1
1010
Summary: Qorus Integration Engine - Qore Python module
1111
License: MIT
@@ -55,6 +55,9 @@ make DESTDIR=%{buildroot} install %{?_smp_mflags}
5555
%{module_dir}
5656

5757
%changelog
58+
* Tue Dec 6 2022 David Nichols <david@qore.org>
59+
- updated to version 1.1.6
60+
5861
* Sat Dec 3 2022 David Nichols <david@qore.org>
5962
- updated to version 1.1.5
6063

src/QorePythonProgram.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -377,22 +377,10 @@ void QorePythonProgram::deleteIntern(ExceptionSink* xsink) {
377377
// enforce serialization
378378
AutoLocker al(py_thr_lck);
379379

380-
// do not clear and delete the interpreter with Python 3.10+
381-
#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 10
382380
assert(_qore_PyRuntimeGILState_GetThreadState());
383381
PyInterpreterState_Clear(interpreter);
384382
}
385383
PyInterpreterState_Delete(interpreter);
386-
#else
387-
// for Python 10+, we only delete the interpreter if initialized by Python
388-
if (qore_needs_shutdown) {
389-
PyInterpreterState_Clear(interpreter);
390-
}
391-
}
392-
if (qore_needs_shutdown) {
393-
PyInterpreterState_Delete(interpreter);
394-
}
395-
#endif
396384

397385
interpreter = nullptr;
398386
owns_interpreter = false;
@@ -464,7 +452,12 @@ QoreValue QorePythonProgram::eval(ExceptionSink* xsink, const QoreString& source
464452
void QorePythonProgram::pythonThreadCleanup(void*) {
465453
int tid = q_gettid();
466454
//printd(5, "QorePythonProgram::pythonThreadCleanup()\n");
467-
AutoLocker al(py_thr_lck);
455+
456+
// issue #4651: when called when the Qore library and the python module are initialized from Java during static
457+
// process destruction, exit handlers may have already destroyed the static objects in this module
458+
if (py_thr_lck.trylock()) {
459+
return;
460+
}
468461

469462
// delete all thread states for the tid
470463
for (auto& i : py_thr_map) {
@@ -482,6 +475,7 @@ void QorePythonProgram::pythonThreadCleanup(void*) {
482475
py_global_tid_map.erase(gi);
483476
}
484477
//printd(5, "QorePythonProgram::pythonThreadCleanup() done\n");
478+
py_thr_lck.unlock();
485479
}
486480

487481
bool QorePythonProgram::haveGil() {

0 commit comments

Comments
 (0)