Commit graph

810 commits

Author SHA1 Message Date
Gabor Kelemen
e1a351ca19 Remove now unneeded osl/diagnose.h
followup to commit 57c228803e

Change-Id: Iebfb23bb65e2bf898bf27f367cc9641f47a14cf3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167998
Reviewed-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
Tested-by: Jenkins
2024-07-20 10:20:31 +02:00
Caolán McNamara
e68f28ec9f cid#1607892 COPY_INSTEAD_OF_MOVE
and

cid#1607910 COPY_INSTEAD_OF_MOVE
cid#1607818 COPY_INSTEAD_OF_MOVE
cid#1557402 COPY_INSTEAD_OF_MOVE
cid#1556530 COPY_INSTEAD_OF_MOVE
cid#1557396 COPY_INSTEAD_OF_MOVE
cid#1556522 COPY_INSTEAD_OF_MOVE
cid#1555628 COPY_INSTEAD_OF_MOVE
cid#1554705 COPY_INSTEAD_OF_MOVE

Change-Id: Iae3fbf4a04bf3714f416995640b9d70fe204cf73
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170321
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-07-11 09:26:28 +02:00
Xisco Fauli
f9cd7e2801 tdf#161947: test setuptools is imported on mac
Change-Id: Ie0908e610b3eade41aa5e7f1953ddaa55afce68d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170173
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2024-07-09 10:28:29 +02:00
Xisco Fauli
4a3706db4f pyuno: fix deprecated warnings
* Replace PyUnicode_FromUnicode(str, len) with PyUnicode_FromWideChar(str, len)
* Replace PyUnicode_AS_UNICODE(PyObject) with PyUnicode_AsWideCharString(PyObject, size)

Change-Id: I1d8b46059d72f4de261d99393e1681f1e41eafdf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169625
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2024-07-05 23:14:52 +02:00
Xisco Fauli
1e2c17a350 tdf#116412: Add unittest
Change-Id: Iab051c91900768a3bf3f26b6de3b443dc18a6928
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169990
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2024-07-04 15:45:15 +02:00
Xisco Fauli
b7bcc716fc pyuno: re-enable pytest_ssl on mac
it was disabled in 731f7fe778
"disable pytest_ssl on mac" with no apparent reason

Change-Id: I7d867ad771f1459a598c4ca346390e732929d705
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169985
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2024-07-04 15:26:52 +02:00
Andrea Gelmini
7cfefdd01b Fix typo
Change-Id: I633ad7aa1a8167795e76bfacfaeec9a42b9db3f5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169157
Tested-by: Julien Nabet <serval2412@yahoo.fr>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2024-06-19 08:39:22 +02:00
Noel Grandin
ed699baa92 workaround clang segfault on macos-intel
Change-Id: Icfced4a990e2d02995bff4078f14b8ee26e9cca3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167497
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-05-11 14:50:28 +02:00
Alain Romedenne
28a43d53b2 Unit tests for officehelper.py
Depend upon previous patch d8978a8c4f for
officehelper.py which fixed some glitches.

Change-Id: Icc5c717d7f0f5a0a08202b6b57e475e7afe6f5c9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164195
Reviewed-by: Hossein <hossein@libreoffice.org>
Tested-by: Jenkins
Tested-by: Hossein <hossein@libreoffice.org>
2024-05-11 11:25:44 +02:00
Noel Grandin
79f4f724b9 loplugin:ostr in pyuno
Change-Id: I54555110b5c66ea92f2675edc50dccd252558e28
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167435
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2024-05-10 13:16:45 +02:00
Ilmari Lauhakangas
da0e9240bf tdf#158447 Use PyConfig for setting Python home directory with Python >= 3.8
Change-Id: Ic5b7c60613b22f5215cb1a2a13fecf3e0946ca49
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161089
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
2024-05-09 09:32:47 +02:00
Christian Lohmaier
0c4c84a14b makefile simplification: replace $(call gb_CustomTarget_get_workdir,foo)
…by a simple/static $(gb_CustomTarget_workdir)/foo

The build system has a lot of overly complicated leftovers from when it
was introduced and had not only deal with split repositories but also
had to coexist with another buildsystem. Along with lots of copy'n'paste
along the years the makefiles became hard to grasp for newcomers with
all our calls and evals.
As a first step to streamline that, the macros from TargetLocations that
simply prefix a static path to the argument (and similar of the same
kind) are a natural pick before simplifying the rules themselves/getting
rid of a bunch of eval statements.

Change-Id: Ia06dbbcd5d1994755a2ff05b84f72ccbc4e3cab5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167005
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
2024-05-03 16:06:14 +02:00
Alain Romedenne
61337efb8c minor fixes to officehelper.py
- erroneous code sample in code comment -retry delays
- fix when raising OSError exception - undefined variable

Change-Id: I2cae4e8b6bbb3153e79f290ae1d316aa22a86b4f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165714
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-04-03 17:50:11 +02:00
Alain Romedenne
2146e66d8d officehelper.py memory cleanup
- main program must stop subprocesses it initiates before it throws exceptions


Change-Id: I6e87d79e2f21cd41f7cd8e470cc166f8d5282954
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164819
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-03-26 21:01:24 +01:00
Stephan Bergmann
dae7304df6 Silence Clang 19 trunk -Werror,-Wcast-function-type-mismatch
Change-Id: Icd0af828e47c770ca8964656188d0d722a7f1ddc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165250
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-03-24 23:13:48 +01:00
Justin Luth
daa04d405a allow build with python 3.12.0: initialize new tp_watched
This fixes the build failure after I updated Ubuntu 24.04 (alpha),
which upgraded python 3.11.7 to python 3.12.0, causing the error:

libreoffice/pyuno/source/module/pyuno_callable.cxx:249:1:
error: missing initializer for member ‘_typeobject::tp_watched’
[-Werror=missing-field-initializers]
...

I gleaned this information from a July 2023 commit for
https://github.com/xbmc/xbmc/issues/23503

tp_watched was added in upstream commit python/cpython@82ccbf6
82ccbf69a8

This change first appeared in Python v3.12.0a1

Change-Id: If82ff1eb47d66d2669d90d6e00e0feff3c55b5ca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164775
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-03-13 17:45:49 +01:00
Gabor Kelemen
ab95ed2c4b Use less boost_headers in low level libraries
Most of these don't use boost themselves, nor do they need
it transitively since the use of boost::optional was removed

Change-Id: Ic9dee1c4e160b313ec5b91677b02ffdea6c5779d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164440
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
2024-03-06 21:23:17 +01:00
Alain Romedenne
d8978a8c4f tdf#116156 tdf#157162 tdf#159528 Fix glitches in officehelper.py
- MacOs & GNU/Linux distributions are supported, next to Windows
- Connection attempts are customisable
- Reporting to console can be configured
- Python source doc. added
- service memory cleanup suggestion examples intended for QA as well as inclusion in wiki pages

officehelper documentation:
https://wiki.documentfoundation.org/Documentation/DevGuide/First_Steps#First_Contact

Change-Id: I6a7c19429e78a1736e4a1479c4bbc1950228d93f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164118
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-03-02 13:00:12 +01:00
Mike Kaganski
8f6b412581 Define a name for the extended path buffer size, instead of a literal
Change-Id: If6d40c818e021b3241d6b6b33aceca07c6393511
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163926
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-02-26 05:59:10 +01:00
Mike Kaganski
08e2c56ced Replace an instance of MAX_PATH with 32767
... which is the approximate maximum of Windows API, as documented in
https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation

Change-Id: I8b10e41d3a8bf85e266f071bdc2eb88eb9403917
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163914
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-02-26 03:20:17 +01:00
Mike Kaganski
7411caca66 Replace an instance of MAX_PATH with 32767
... which is the approximate maximum of Windows API, as documented in
https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation

Change-Id: I22aecd9b9e1423b74b61985cad11bb3c194f2bdc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163913
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-02-26 03:20:04 +01:00
Mike Kaganski
3234c4e35f Avoid MAX_PATH limitation in launcher
... and drop some manual memory management.

Change-Id: I4c60ce559ff185d4685a6b9799a97651438115b1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162502
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-02-25 07:29:40 +01:00
Aron Budea
6efe49e729 pyuno: Use expected return value (-1) on failure
Both PyObject_SetAttr and PyObject_SetItem are expected to:

Raise an exception and return -1 on failure; return 0 on success.
https://docs.python.org/3/c-api/object.html

Change-Id: Id1f6129e91e9da2f5d3bc1858422eeee4c3393d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163418
Tested-by: Jenkins
Reviewed-by: Aron Budea <aron.budea@collabora.com>
2024-02-15 12:49:31 +01:00
Mike Kaganski
0fa827dbb2 Drop std::as_const from css::uno::Sequence iterations
Obsoleted by commit 2484de6728 (Remove
non-const Sequence::begin()/end() in internal code, 2021-10-15) and
commit fb3c04bd19 (Drop non-const
Sequence::operator[] in internal code, 2021-11-05).

Change-Id: Idbafef5d34c0d4771cbbf75b9db9712e504164cd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162640
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-01-27 12:43:48 +01:00
Chenxiong Qi
74de0ebb81 tdf#97361 Make unittests more pythonic: XIndexAccess
Change-Id: I05ef274dd0ad5dc35b5455cfc01feabc6c0820a3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161276
Tested-by: Jenkins
Reviewed-by: Hossein <hossein@libreoffice.org>
2024-01-23 14:00:46 +01:00
Stephan Bergmann
208a637796 Add back XComponentContext to officecfg::...::get() calls
4256c764ae "do not pass XComponentContext to
officecfg::...::get() calls" had removed it, for performance reasons, but
8a695046cf "tdf#158375 Hack to make sure process
service factory is set" is a case where it should be passed in.  To hopefully
avoid performance regressions, don't default to
comphelper::getProcessComponentContext() for what gets passed in, but default to
an empty Reference and only call comphelper::getProcessComponentContext() when
actually needed in the implementation.

Change-Id: I5b75ac2c28f36e21d1c8bc368b0b972c33c61a51
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162205
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-01-17 21:33:02 +01:00
Stephan Bergmann
8a695046cf tdf#158375 Hack to make sure process service factory is set
(TODO: A more clean fix would pass XComponentContext into the configuration
wrapper.)

Change-Id: I1936a4517877f30cc7a825ce1c94923b350f7173
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162198
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-01-17 19:02:49 +01:00
Sarper Akdemir
5372538648 tdf#158375: add expert option DisablePythonRuntime
When DisablePythonRuntime is set, anything that utilizes pyuno
bindings won't work (e.g. python macros and extensions).

Change-Id: Id42d01647eebee42b120b399470a1f944e4ba00f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160968
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
2024-01-09 00:48:18 +01:00
Chenxiong Qi
8b6e0dd9e4 tdf#158803 Fix issues detected by pyflakes
Change-Id: Iaa329dff61db894e7d5fecd840e785a53a48b26f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160889
Tested-by: Jenkins
Reviewed-by: Hossein <hossein@libreoffice.org>
2023-12-27 13:48:47 +01:00
Stephan Bergmann
115e7a00c3 Extended loplugin:ostr: pyuno
Change-Id: Ie8ec1e8b3debd1501b16d40567a063390749a19b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159683
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-11-19 20:39:16 +01:00
sahil
c0e687edf4 tdf#130924 replace '*printf' with 'SAL_*' logging macros in pyuno
Change-Id: I2c491629f52fe0b90517c563f221d7d0345b6ee9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156452
Tested-by: Jenkins
Reviewed-by: Hossein <hossein@libreoffice.org>
2023-10-23 16:54:59 +02:00
Mike Kaganski
176e8cf09a Use exception ctors, instead of setting members later
Avoids overwriting source location in message

Change-Id: Ia0290c7dd1ab3ea1357712a27ecab75c7b583dd4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157893
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-10-14 15:37:17 +02:00
Caolán McNamara
86160b081b cid#1546834 Unchecked return value
Change-Id: Id2c54c61d3d44611ab02db81b8e64cedb0010ba7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157398
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-09-29 14:14:13 +02:00
Szymon Kłos
e78f60a369 Categories for link targets in Impress
Writer and Calc presented possible link targets inside
documents as a Tree, with items under their categories.
This patch makes the same for Impress so we don't mix
master pages with regular pages.

Change-Id: Ifd98300b0d609c28d6c1880332fff7e750b5e1b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152389
Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153985
Tested-by: Jenkins
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
2023-07-12 07:56:37 +02:00
Caolán McNamara
c7b4d15c5c WaE: Py_SetPythonHome is deprecated since python 3.11
not obvious how to replace it, so just accept for now

Change-Id: Id3fc4c95a5cc60e078f06faaa024faa9c770de20
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152504
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-06-01 18:23:28 +02:00
Stephan Bergmann
1c8df0fd1a loplugin:stringadd
Change-Id: I04dad33cad121eba7189fc78cac762e31d7c4c2c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150477
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-04-17 11:42:07 +02:00
Noel Grandin
7f91e4a982 loplugin:stringadd in oox..pyuno
after my patch to merge the bufferadd loplugin into stringadd

Change-Id: I5fdc0a33923fe00e7b588f4576607515a93e5c13
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149579
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-03-27 11:04:46 +00:00
buldi
8ca611b212 tdf#143148 Use pragma once instead of include guards
Change-Id: I5a88b699425a37b914a71400e918965a9f6116eb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146730
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2023-02-13 11:26:27 +00:00
Bogdan B
de419b94b3 Remove unused imports from pyuno/demo and pyuno/qa
Change-Id: I777eb19059030d2c1ce870b5839b541cbc7e90d8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142520
Tested-by: Jenkins
Reviewed-by: Hossein <hossein@libreoffice.org>
2023-01-02 09:37:00 +00:00
Mike Kaganski
2875d11939 tdf#150982: properly unquote (URL-decode) vnd.sun.star.expand payload
Similar to what is done in bootstrap_expandUri, expandUnoRcUrl,
UrlReference::expand, JavaLoader.expand_url, and is documented
in XVndSunStarExpandUrl interface.

Change-Id: I92917adb38e42c3926494427e4df2451298033e0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140042
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-09-16 12:55:06 +02:00
Chenxiong Qi
9928f139e8 tdf#97361 replace getCellByPosition with access by subscript
Signed-off-by: Chenxiong Qi <qcxhome@gmail.com>
Change-Id: I50d6e29c34e3cf72cdf0afc9f118fafc3c144eaf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139141
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-05 16:05:56 +02:00
Chenxiong Qi
14cff82b31 tdf#97361 replace getCellRangeByPosition with slices
Signed-off-by: Chenxiong Qi <qcxhome@gmail.com>
Change-Id: I4368adca1e9500c6f926ea1f28b0790b06fae739
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139140
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-05 16:05:28 +02:00
Noel Grandin
1743d74e87 clang-tidy modernize-pass-by-value in various
Change-Id: Ie091b22bd77d4e1fbff46545bc86c12f1dbafcfe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138171
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-13 19:11:49 +02:00
Noel Grandin
4c909d1466 loplugin:passstuffbyref
Change-Id: Ib2b2650da7abc9260897f9b5aad619a0ea6ae941
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138052
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-10 08:07:03 +02:00
Niko Fink
1052ec9cff tdf#133123: fix crash when importing defusedxml.ElementTree after pyuno
Change-Id: I89ac6108c679504c81dd9a439a4fb02e9e1adc07
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138007
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2022-08-09 11:55:38 +02:00
Noel Grandin
e7903c01b1 elide some makeStringAndClear() calls
Change-Id: I3b80d0f5b6d39c071242bc6ccc1e4333886c835d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137309
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-07-22 11:14:37 +02:00
Stephan Bergmann
1638b4f78a rhbz#2097411 Avoid obsolete PyThreadState_Delete crashing Python 3.11
1fb53a6375 "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
<https://gerrit.libreoffice.org/c/core/+/3452/2#message-602ff52abdd1c95fd5c13cfe405b5fadd0048c5f>
"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 0x0000ffff81c8b020 (most recent call first):
>   <no Python frame>
> Fatal exception: Signal 6
> Stack:
> /builddir/build/BUILD/libreoffice-7.3.4.2/instdir/program/libuno_sal.so.3(+0x37c28)[0xffff81be7c28]
> /builddir/build/BUILD/libreoffice-7.3.4.2/instdir/program/libuno_sal.so.3(+0x37e40)[0xffff81be7e40]
> linux-vdso.so.1(__kernel_rt_sigreturn+0x0)[0xffff81ccb7ec]
> /lib64/libc.so.6(+0x82878)[0xffff81742878]
> /lib64/libc.so.6(raise+0x20)[0xffff816fae00]
> /lib64/libc.so.6(abort+0xe8)[0xffff816e72b8]
> /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)[0xffff815544b4]

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 <sbergman@redhat.com>
2022-06-16 22:40:28 +02:00
Stephan Bergmann
51c9862303 Just use Any ctor instead of makeAny in pyuno
Change-Id: I53eb836c64e8e4a354c5c895bc7f16b168bd4cf3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133793
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-05-04 08:41:43 +02:00
Noel Grandin
33bd16b344 loplugin:stringviewparam convert methods using copy()
which converts to std::string_view::substr()

Change-Id: I3f42213b41a97e77ddcc79d84d512f49d68ca559
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132729
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-04-17 10:27:33 +02:00
Stephan Bergmann
b3b18ed165 Don't make UNO calls from PyThreadAttached regions (i.e., with the GIL locked)
...which caused e.g. UITest_writer_tests3 to occasionally hang with the
python.bin process thread 1 at

>   File "sw/qa/uitest/writer_tests3/insertPageFooter.py", line 30, in delete_footer
[...]

i.e.,

> #4  ___pthread_cond_wait at /usr/src/debug/glibc-2.35-4.fc36.x86_64/nptl/pthread_cond_wait.c:618
> #5  0x00007ff9d6ad9c43 in cppu_threadpool::JobQueue::enter(void const*, bool) at cppu/source/threadpool/jobqueue.cxx:72
> #6  0x00007ff9d6ae8e79 in cppu_threadpool::ThreadPool::enter(rtl::ByteSequence const&, void const*) at cppu/source/threadpool/threadpool.cxx:303
> #7  0x00007ff9d6ae9278 in uno_threadpool_enter(uno_ThreadPool, void**) at cppu/source/threadpool/threadpool.cxx:407
> #8  0x00007ff9c7d016eb in binaryurp::Bridge::makeCall(rtl::OUString const&, com::sun::uno::TypeDescription const&, bool, std::__debug::vector<binaryurp::BinaryAny, std::allocator<binaryurp::BinaryAny> >&&, binaryurp::BinaryAny*, std::__debug::vector<binaryurp::BinaryAny, std::allocator<binaryurp::BinaryAny> >*) at binaryurp/source/bridge.cxx:604
> #9  0x00007ff9c7d322fc in binaryurp::Proxy::do_dispatch_throw(_typelib_TypeDescription const*, void*, void**, _uno_Any**) const at binaryurp/source/proxy.cxx:168
> #10 0x00007ff9c7d338cb in binaryurp::Proxy::do_dispatch(_typelib_TypeDescription const*, void*, void**, _uno_Any**) const at binaryurp/source/proxy.cxx:101
> #11 0x00007ff9d63222e0 in cpp2uno_call(bridges::cpp_uno::shared::CppInterfaceProxy*, typelib_TypeDescription const*, typelib_TypeDescriptionReference*, sal_Int32, typelib_MethodParameter*, void**, void**, void**, sal_uInt64*) at bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx:191
> #12 0x00007ff9d6322b59 in cpp_vtable_call(sal_Int32, sal_Int32, void**, void**, void**, sal_uInt64*) at bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx:389
> #13 0x00007ff9d63336ca in privateSnippetExecutor at instdir/program/libgcc3_uno.so
> #14 0x00007ff9d6241f38 in (anonymous namespace)::ImplIntrospectionAccess::hasByName(rtl::OUString const&) at stoc/source/inspect/introspection.cxx:1114
> #15 0x00007ff9d6b856b2 in pyuno::PyUNO_getattr(PyObject*, char*) at pyuno/source/module/pyuno.cxx:1392
[...]

doing a remote call to soffice.bin with GIL locked, and thread 4 at

> #6  0x00007ff9e51efa28 in take_gil at workdir/UnpackedTarball/python3/Python/ceval_gil.h:207
> #7  0x00007ff9e51f00d3 in PyEval_AcquireThread at workdir/UnpackedTarball/python3/Python/ceval.c:316
> #8  0x00007ff9d6b9b1e8 in pyuno::Adapter::invoke(rtl::OUString const&, com::sun::uno::Sequence<com::sun::uno::Any> const&, com::sun::uno::Sequence<short>&, com::sun::uno::Sequence<com::sun::uno::Any>&) at pyuno/source/module/pyuno_adapter.cxx:181
> #9  0x00007ff9d632b3e4 in gcc3::callVirtualMethod(void*, unsigned int, void*, _typelib_TypeDescriptionReference*, bool, unsigned long*, unsigned int, unsigned long*, double*) at bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx:77
> #10 0x00007ff9d632a4f1 in cpp_call(bridges::cpp_uno::shared::UnoInterfaceProxy*, bridges::cpp_uno::shared::VtableSlot, typelib_TypeDescriptionReference*, sal_Int32, typelib_MethodParameter*, void*, void**, uno_Any**) at bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:233
> #11 0x00007ff9d632a9e6 in bridges::cpp_uno::shared::unoInterfaceProxyDispatch(uno_Interface*, typelib_TypeDescription const*, void*, void**, uno_Any**) at bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:413
> #12 0x00007ff9d621384a in stoc_invadp::(anonymous namespace)::AdapterImpl::invoke at stoc/source/invocation_adapterfactory/iafactory.cxx:457
> #13 stoc_invadp::adapter_dispatch(uno_Interface*, typelib_TypeDescription const*, void*, void**, uno_Any**) at stoc/source/invocation_adapterfactory/iafactory.cxx:605
> #14 0x00007ff9c7d1a7db in binaryurp::IncomingRequest::execute_throw(binaryurp::BinaryAny*, std::__debug::vector<binaryurp::BinaryAny, std::allocator<binaryurp::BinaryAny> >*) const at include/typelib/typedescription.hxx:155
> #15 0x00007ff9c7d1d65f in binaryurp::IncomingRequest::execute() const at binaryurp/source/incomingrequest.cxx:78
> #16 0x00007ff9c7d33ad3 in binaryurp::(anonymous namespace)::request(void*) at ~/gcc/trunk/inst/include/c++/12.0.1/bits/unique_ptr.h:172
> #17 0x00007ff9d6ad9e1b in cppu_threadpool::JobQueue::enter(void const*, bool) at cppu/source/threadpool/jobqueue.cxx:100
> #18 0x00007ff9d6adbb80 in cppu_threadpool::ORequestThread::run() at cppu/source/threadpool/thread.cxx:164
[...]

processing an unrelated incoming call from soffice.bin and blocked trying to
lock the GIL.  (The reason that thread 1 doesn't make progress is that the
soffice.bin process is also blocking with thread 6 at

> #8  osl::Guard<comphelper::SolarMutex>::Guard(comphelper::SolarMutex&) at include/osl/mutex.hxx:142
> #9  SolarMutexGuard::SolarMutexGuard() at include/vcl/svapp.hxx:1368
> #10 sw::(anonymous namespace)::XStyleFamily::hasByName(rtl::OUString const&) at sw/source/core/unocore/unostyle.cxx:923
> #11 0x00007f089d3d53e4 in gcc3::callVirtualMethod(void*, unsigned int, void*, _typelib_TypeDescriptionReference*, bool, unsigned long*, unsigned int, unsigned long*, double*) at bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx:77
> #12 0x00007f089d3d44f1 in cpp_call(bridges::cpp_uno::shared::UnoInterfaceProxy*, bridges::cpp_uno::shared::VtableSlot, typelib_TypeDescriptionReference*, sal_Int32, typelib_MethodParameter*, void*, void**, uno_Any**) at bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:233
> #13 0x00007f089d3d49e6 in bridges::cpp_uno::shared::unoInterfaceProxyDispatch(uno_Interface*, typelib_TypeDescription const*, void*, void**, uno_Any**) at bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:413
> #14 0x00007f089c1be7db in binaryurp::IncomingRequest::execute_throw(binaryurp::BinaryAny*, std::__debug::vector<binaryurp::BinaryAny, std::allocator<binaryurp::BinaryAny> >*) const at include/typelib/typedescription.hxx:155
> #15 0x00007f089c1c165f in binaryurp::IncomingRequest::execute() const at binaryurp/source/incomingrequest.cxx:78
> #16 0x00007f089c1d7ad3 in binaryurp::(anonymous namespace)::request(void*) at ~/gcc/trunk/inst/include/c++/12.0.1/bits/unique_ptr.h:172
> #17 0x00007f08a18ade1b in cppu_threadpool::JobQueue::enter(void const*, bool) at cppu/source/threadpool/jobqueue.cxx:100
> #18 0x00007f08a18afb80 in cppu_threadpool::ORequestThread::run() at cppu/source/threadpool/thread.cxx:164
[...]

processing the incoming call from python.bin thread 1 and blocked trying to lock
the SolarMutex, while thread 1 at

> #4  ___pthread_cond_wait at /usr/src/debug/glibc-2.35-4.fc36.x86_64/nptl/pthread_cond_wait.c:618
> #5  0x00007f08a18adc43 in cppu_threadpool::JobQueue::enter(void const*, bool) at cppu/source/threadpool/jobqueue.cxx:72
> #6  0x00007f08a18bce79 in cppu_threadpool::ThreadPool::enter(rtl::ByteSequence const&, void const*) at cppu/source/threadpool/threadpool.cxx:303
> #7  0x00007f08a18bd278 in uno_threadpool_enter(uno_ThreadPool, void**) at cppu/source/threadpool/threadpool.cxx:407
> #8  0x00007f089c1a56eb in binaryurp::Bridge::makeCall(rtl::OUString const&, com::sun::uno::TypeDescription const&, bool, std::__debug::vector<binaryurp::BinaryAny, std::allocator<binaryurp::BinaryAny> >&&, binaryurp::BinaryAny*, std::__debug::vector<binaryurp::BinaryAny, std::allocator<binaryurp::BinaryAny> >*) at binaryurp/source/bridge.cxx:604
> #9  0x00007f089c1d62fc in binaryurp::Proxy::do_dispatch_throw(_typelib_TypeDescription const*, void*, void**, _uno_Any**) const at binaryurp/source/proxy.cxx:168
> #10 0x00007f089c1d78cb in binaryurp::Proxy::do_dispatch(_typelib_TypeDescription const*, void*, void**, _uno_Any**) const at binaryurp/source/proxy.cxx:101
> #11 0x00007f089d3cc2e0 in cpp2uno_call(bridges::cpp_uno::shared::CppInterfaceProxy*, typelib_TypeDescription const*, typelib_TypeDescriptionReference*, sal_Int32, typelib_MethodParameter*, void**, void**, void**, sal_uInt64*) at bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx:191
> #12 0x00007f089d3ccb59 in cpp_vtable_call(sal_Int32, sal_Int32, void**, void**, void**, sal_uInt64*) at bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx:389
> #13 0x00007f089d3dd6ca in privateSnippetExecutor at instdir/program/libgcc3_uno.so
> #14 0x00007f08a6b5d170 in operator() at sfx2/source/notify/globalevents.cxx:491
> #15 comphelper::OInterfaceContainerHelper4<com::sun::document::XDocumentEventListener>::forEach<(anonymous namespace)::SfxGlobalEvents_Impl::implts_notifyListener(const com::sun::document::DocumentEvent&)::<lambda(const com::sun::uno::Reference<com::sun::document::XDocumentEventListener>&)> > at include/comphelper/interfacecontainer4.hxx:285
> #16 at sfx2/source/notify/globalevents.cxx:488
> #17 0x00007f08a6b04c8b in (anonymous namespace)::NotifySingleListenerIgnoreRE<com::sun::document::XDocumentEventListener, com::sun::document::DocumentEvent>::operator() (listener=Python Exception <class 'gdb.error'>: Dwarf Error: Cannot find DIE at 0x0 referenced in module instdir/program/libmergedlo.so
> #18 comphelper::OInterfaceContainerHelper2::forEach<com::sun::document::XDocumentEventListener, at include/comphelper/interfacecontainer2.hxx:271
> #19 SfxBaseModel::postEvent_Impl(rtl::OUString const&, com::sun::uno::Reference<com::sun::frame::XController2> const&, com::sun::uno::Any const&) at sfx2/source/doc/sfxbasemodel.cxx:3253
> #20 0x00007f08a6b066fe in SfxBaseModel::Notify(SfxBroadcaster&, SfxHint const&) at sfx2/source/doc/sfxbasemodel.cxx:2902
> #21 0x00007f08a6f15def in SfxBroadcaster::Broadcast(SfxHint const&) at svl/source/notify/SfxBroadcaster.cxx:39
> #22 0x00007f087d640650 in SwLayIdle::SwLayIdle(SwRootFrame*, SwViewShellImp*) at sw/source/core/layout/layact.cxx:2389
> #23 0x00007f087dc0832b in SwViewShell::LayoutIdle() at sw/source/core/view/viewsh.cxx:821
> #24 0x00007f087d2ba194 in sw::DocumentTimerManager::DoIdleJobs(Timer*) at sw/source/core/inc/rootfrm.hxx:206
> #25 0x00007f08a89fbd26 in Scheduler::CallbackTaskScheduling() at vcl/source/app/scheduler.cxx:472
> #26 0x00007f08a8ca8780 in SalTimer::CallCallback() at vcl/inc/saltimer.hxx:54
> #27 SvpSalInstance::CheckTimeout(bool) at vcl/headless/svpinst.cxx:212
> #28 0x00007f08a8ca99bd in SvpSalInstance::ImplYield(bool, bool) at vcl/headless/svpinst.cxx:452
> #29 0x00007f08a8ca9db1 in SvpSalInstance::DoYield(bool, bool) at vcl/headless/svpinst.cxx:524
> #30 0x00007f08a8a27d4c in ImplYield(bool, bool) at vcl/source/app/svapp.cxx:474
> #31 0x00007f08a8a28445 in Application::Execute() at vcl/source/app/svapp.cxx:452
[...]

is doing the remote call to python.bin thread 4 with the SolarMutex erroneously
locked.  But lets concentrate on just fixing the python.bin deadlock in this
commit.)

The PyThreadDetach antiguard just covering the xInvocation->getValue call in the
"or a property" case had been added with
e0a1cd4dc7 "fixed a deadlock", presumably without
taking into account that the xInvocation->hasMethod/hasProperty calls are
equally problematic.

Change-Id: I2483949df8213c3397a674be190224ee58c95c02
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132428
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-04-01 16:56:58 +02:00