[Libreoffice-commits] core.git: Branch 'libreoffice-7-3' - pyuno/source

2022-06-17 Thread Stephan Bergmann (via logerrit)
 pyuno/source/loader/pyuno_loader.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit e90f3bef395cd4a1dd0302202476531a6ecb735d
Author: Stephan Bergmann 
AuthorDate: Thu Jun 16 18:58:18 2022 +0200
Commit: Michael Stahl 
CommitDate: Fri Jun 17 10:23:26 2022 +0200

rhbz#2097411 Avoid obsolete PyThreadState_Delete crashing Python 3.11

1fb53a637597f76bea86514b62ddfad34f60c889 "pyuno_loader::CreateInstance: 
delete
the initial PyThreadState" had added the PyThreadState_Delete for claimed
benefits but whose details appear lost to history (cf. the comment thread
starting at


"pyuno_loader::CreateInstance: delete the initial PyThreadState").  And at 
least
a recent master Linux --enable-python=fully-internal build with the bundled
Python 3.8.12 appears to succeed `make check` just fine with the
PyThreadState_Delete temporarily removed.

But on the other hand, building against upcoming Python 3.11 now started to 
make
CppunitTest_services fail with

> Fatal Python error: init_threadstate: thread state already initialized
> Python runtime state: initialized
> Thread 0x81c8b020 (most recent call first):
>   
> Fatal exception: Signal 6
> Stack:
> 
/builddir/build/BUILD/libreoffice-7.3.4.2/instdir/program/libuno_sal.so.3(+0x37c28)[0x81be7c28]
> 
/builddir/build/BUILD/libreoffice-7.3.4.2/instdir/program/libuno_sal.so.3(+0x37e40)[0x81be7e40]
> linux-vdso.so.1(__kernel_rt_sigreturn+0x0)[0x81ccb7ec]
> /lib64/libc.so.6(+0x82878)[0x81742878]
> /lib64/libc.so.6(raise+0x20)[0x816fae00]
> /lib64/libc.so.6(abort+0xe8)[0x816e72b8]
> /lib64/libpython3.11.so.1.0(+0x104e28)[0xfffee4de4e28]
> /lib64/libpython3.11.so.1.0(+0x105200)[0xfffee4de5200]
> 
/lib64/libpython3.11.so.1.0(PyThread_get_thread_native_id+0x0)[0xfffee4ed6764]
> /lib64/libpython3.11.so.1.0(PyThreadState_New+0x14)[0xfffee4ed6628]
> 
/builddir/build/BUILD/libreoffice-7.3.4.2/instdir/program/libpyuno.so(_ZN5pyuno14PyThreadAttachC2EP3_is+0x78)[0xfffee4c8c52c]
> 
/builddir/build/BUILD/libreoffice-7.3.4.2/instdir/program/libpythonloaderlo.so(pyuno_Loader_get_implementation+0x5c)[0xfffee5243060]
> 
/builddir/build/BUILD/libreoffice-7.3.4.2/instdir/program/libuno_cppuhelpergcc3.so.3(+0x544b4)[0x815544b4]

because of the PyThreadState_Delete.  (The deleted PyThreadState, while not
reused again directly, is still recorded in the state obtained from
PyInterpreterState_Head() later.)

So conservatively keep the PyThreadState_Delete of unclear benefit for older
Python versions and only drop it for 3.11 where it is known to have negative
effects now.

Change-Id: I9b99f1e947f0b165ddc95c2bfbd764858dda39db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136006
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 
(cherry picked from commit 1638b4f78af70b7b97d0a081ed51390dd87bf1f9)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136025
Reviewed-by: Michael Stahl 

diff --git a/pyuno/source/loader/pyuno_loader.cxx 
b/pyuno/source/loader/pyuno_loader.cxx
index 0db6e637a2a7..4a69c410db25 100644
--- a/pyuno/source/loader/pyuno_loader.cxx
+++ b/pyuno/source/loader/pyuno_loader.cxx
@@ -229,10 +229,12 @@ void pythonInit() {
 
 PyThreadState *tstate = PyThreadState_Get();
 PyEval_ReleaseThread( tstate );
+#if PY_VERSION_HEX < 0x030B
 // This tstate is never used again, so delete it here.
 // This prevents an assertion in PyThreadState_Swap on the
 // PyThreadAttach below.
 PyThreadState_Delete(tstate);
+#endif
 }
 
 }


[Libreoffice-commits] core.git: Branch 'libreoffice-7-3' - pyuno/source

2022-01-10 Thread Mike Kaganski (via logerrit)
 pyuno/source/module/pyuno_gc.cxx |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 1dff55f964bcf4a5c3fc1c1381d706125262bc2b
Author: Mike Kaganski 
AuthorDate: Fri Jan 7 11:21:31 2022 +0300
Commit: Xisco Fauli 
CommitDate: Mon Jan 10 18:39:24 2022 +0100

tdf#146621: handle an exception that may hang process at ExitProcess time

Change-Id: I3ffc2303ae1851ab909612ae9bb7f70a077b24fe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128097
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit 639419601a3730eb84d0922ef3a540c961b81910)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128157
Reviewed-by: Xisco Fauli 

diff --git a/pyuno/source/module/pyuno_gc.cxx b/pyuno/source/module/pyuno_gc.cxx
index e4ed6cb9d0a6..1efca400d510 100644
--- a/pyuno/source/module/pyuno_gc.cxx
+++ b/pyuno/source/module/pyuno_gc.cxx
@@ -111,11 +111,20 @@ void decreaseRefCount( PyInterpreterState *interpreter, 
PyObject *object )
 // to be a method, which tells, whether the global
 // interpreter lock is held or not
 // TODO: Look for a more efficient solution
-rtl::Reference< GCThread >(new GCThread(interpreter, object))->launch();
+try
+{
+rtl::Reference< GCThread >(new GCThread(interpreter, 
object))->launch();
 //TODO: a protocol is missing how to join with the launched thread
 // before exit(3), to ensure the thread is no longer relying on any
 // infrastructure while that infrastructure is being shut down in
 // atexit handlers
+}
+catch (std::runtime_error&)
+{
+// tdf#146621: Thread creation will fail on Windows with 
ERROR_ACCESS_DENIED
+// when called at ExitProcess time; unhandled exception would hang the 
process
+abort();
+}
 }
 
 }