Commit Graph
1085 Commits
Author SHA1 Message Date
Balazs Varga c00a23393a tdf#157943 embeddedobj: refuse OLE-link edit when source is in use
After reverting 2b4cd99d, editing an OLE link whose source is already
open in this LO instance produces a sharing-violation on save (the
intra-process scenario tdf#126742 was working around).

Detect the conflict at doVerb, gated to verbs targeting a visible
state so internal RUNNING transitions aren't intercepted. If the
source is loaded as another visible frame in this LO, switch to that
window (matches MSO behaviour). Otherwise probe for any .~lock or
MSO ~$ file - foreign user, hidden own frame, or stale own lock from
a crash - and show an async warning with the lock owner. In all
cases the OLE working copy is never created. Skipped in headless
mode.

Change-Id: Ic87bb6f073b0b04ec47597cc15f2c5a83cc2bffc
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/2004
Reviewed-by: Michael Stahl <michael.stahl@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204940
Reviewed-by: Balazs Varga <balazs.varga@collabora.com>
Tested-by: Jenkins
2026-05-10 09:28:22 +02:00
Xisco Fauli cfd3309a5d loplugin:unusedmethods
Check existing ones that can be removed

Change-Id: I6ee6fc1772c620ac5d12fea915681b094b7c3bfd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204583
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-04-30 08:54:45 +02:00
Caolán McNamara 1ceac1a378 check if the readBytes could be satisfied
Change-Id: I1db61c215963882754a775ddd502d47378c7ef81
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202522
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
2026-03-24 09:12:08 +01:00
Michael Weghorn ab3635b2f3 weld: Move weld::MessageDialog to own header
Move the class out of weld.hxx into its own header, in
order to make it easier to keep an overview and to avoid
having to recompile ~all UI code when the class is
modified.

Change-Id: I5b23b02151c75bb49831a2bbf8d515eb0b54415e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199068
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2026-02-11 07:32:45 +01:00
Gabor Kelemen 495fa42afa tdf#146619 Use more forward declarations in include/vcl/weld/
after recent split of these headers

This shaves off another 150M input

Change-Id: Ia4e42781cdc6fd6e795c9fb55c6c24dd641b8f0d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197339
Reviewed-by: Gabor Kelemen <gabor.kelemen@collabora.com>
Tested-by: Jenkins
2026-01-31 11:06:42 +01:00
Gabor Kelemen f8dad0daf9 tdf#146619 Use more forward declarations in include/vcl/svapp.hxx
this was skipped in previous runs, since it contains some code behind #if

After inspecting these, it seems like the removals should not cause trouble.

Change-Id: If1e3e3c7c0fc14ed6e8b51174a0e7f1220fdbc8b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197496
Tested-by: Jenkins
Reviewed-by: Gabor Kelemen <gabor.kelemen@collabora.com>
2026-01-25 13:31:57 +01:00
Mike Kaganski 3a54d9870f Simplify use of COMReference a bit
1. Avoid explicitly specifying COM_QUERY in calls to QueryInterface
   (it is implied from the name).
2. Drop redundant ctor and set() that duplicate QueryInterface.
3. Allow ThrowIfFailed without a message.

Change-Id: I75b545e534efb7e57da131dfd40a2a49d204efac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198033
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2026-01-24 13:36:50 +01:00
Gabor Kelemen 31ea498486 tdf#146619 Use more forward declarations in include/vcl/[q-w]*
Found after running bin/find-unneeded-includes --headersfwd include/vcl/[q-w]*

This shaves off about 100M input

Change-Id: Ib4d0af44b383d34d856a9797fe70a974b359402f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196398
Tested-by: Jenkins
Reviewed-by: Gabor Kelemen <gabor.kelemen@collabora.com>
2026-01-18 00:33:10 +01:00
Xisco Fauli 4681a262db embeddedobj: drop macro
since
commit d7e9570b52
Author: Vladimir Glazounov <vg@openoffice.org>
Date:   Wed Nov 1 17:20:30 2006 +0000

    INTEGRATION: CWS inplaceobjects (1.24.20); FILE MERGED

Change-Id: I495822321fb6e310438face7fe9e947353c13d75
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197126
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-01-14 08:54:38 +01:00
Xisco Fauli eff4bc45f9 embeddedobj: pass OCommonEmbeddedObject by ref
Change-Id: I7308d32e22b99a8f14aed45bbf469aadcc5ca5c7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197125
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-01-13 09:48:49 +01:00
Michael Weghorn 5b16b3acc6 weld: Move weld.hxx and weldutils.hxx to new include/vcl/weld subdir
This is in preparation of moving code out of weld.hxx
to separate headers/source files, in order to make it
easier to keep an overview and to avoid having to
recompile ~all UI code when anything changes.

Also move weldutils.cxx to a new vcl/source/weld
directory.

Change-Id: Ia75b42f21e560dd248307282a522f186a64cd742
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195777
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2025-12-17 18:20:13 +01:00
Mike Kaganski b280efcb9b Drop some uses Sequence::getConstArray
Replace by operator[], begin() and end(), which don't have overhead
since 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: I221470b3439bb0dc6e7705b0d99deb3cd2063484
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195176
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-12-07 12:54:23 +01:00
Mike Kaganski 7f198b27f4 Drop class utl::MediaDescriptor, and use comphelper::SequenceAsHashMap
utl::MediaDescriptor was just a SequenceAsHashMap with a few added
methods. It made it more difficult to assign a SequenceAsHashMap to
MediaDescriptor, without real upsides. In many places, the class was
used not as media descriptor, but just as helper to create sequences.

This change puts the string constants and the former methods into a
namespace utl::MediaDescriptor.

It would be also good to drop comphelper::NamedValueCollection, which
is basically a twin of comphelper::SequenceAsHashMap (TODO).

Change-Id: Ia9b69c5a2ad153ecc654944c419c1880252ed86e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195163
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-12-06 18:18:32 +01:00
Karthik Godha 258face115 tdf#169539: PPT->PPTX Draw OLE object data loss
Draw OLE objects are skipped during the export of PPTX.

Change-Id: I21c328a3e322de9fc3d4a18030e53894e7fa2514
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194216
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Stahl <michael.stahl@collabora.com>
(cherry picked from commit f6b22383258d6ecd93193240b60d6124791d8699)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195047
Tested-by: Jenkins
2025-12-05 14:13:21 +01:00
Gabor Kelemen 3ea68d1b8d tdf#146619 Run IWYU on e...
embeddedobj/ emfio/ extensions/ eventattacher/

Change-Id: I7a86b19d1c5ff3859cb5f97a4ef74cf8e01de3b6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190909
Tested-by: Jenkins
Reviewed-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
2025-09-23 16:24:45 +02:00
Mike Kaganski a255b04d8d Shorten some names ending with _ASCII
Whatever that was intended to mean: if that meant that the constants
were encoded that way, these are UTF-16 already; is that meant that
they only contained characters in that range, that is unimportant.

Change-Id: I5463f1fca0d552a93d3c9d487ed9912c9e1a989e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191240
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2025-09-20 19:35:12 +02:00
Noel Grandin d35a23cbda EmbeddedUpdate should not use the css namespace
that is for the UNO API stuff, using it just makes the code harder to read

Change-Id: I01ac7672aa993842a889cdb8bcc05137efc80ee0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190938
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2025-09-15 13:34:35 +02:00
Caolán McNamara 72e538b9bd tainted_data_return is deprecated
in favour of taint_source, lets drop them all first

Change-Id: I9c4e5c143fcbd6de9491360c993a8ea1b89a726e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189820
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2025-08-17 15:33:16 +02:00
Noel Grandin 03caa7db14 tdf#167073 Extension MRI does not start
revert
    commit 39f2c62847
    simplify TaskCreatorService
and
    commit 96b6d13c9a.
    [API CHANGE] no need for TaskCreatorService to be exposed via UNO

I missed that this service is in use.

Change-Id: I97b01668f7ba313335f9fbd8cf0e398dfc1b5ca0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186643
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2025-06-18 15:26:32 +02:00
Noel Grandin 39f2c62847 simplify TaskCreatorService
now that it is no longer an UNO service, we can simplify it,
and returning a more explicit type.

Change-Id: Ibd0f56e04ac26f09b57dc295febcf26202f16a2a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186495
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2025-06-14 19:34:10 +02:00
Noel Grandin 96b6d13c9a [API CHANGE] no need for TaskCreatorService to be exposed via UNO
This is a purely internal usage thing.

Change-Id: I8d13d21c791bc88a2fc288fb97f7877eecab3e73
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186494
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2025-06-14 19:34:01 +02:00
Gabor Kelemen 924ab1962e Remove obsolete fw declarations from embeddedobj/ extensions/
found with bin/find-unneeded-includes --fwdecl

Change-Id: I029145e0f04b1ed90bb0d16c871891bca85b39a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183885
Tested-by: Jenkins
Reviewed-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
2025-04-17 00:22:52 +02:00
Devashish Gupta 797292f65b tdf#42982 Improve UNO API error reporting
Change-Id: Icba16d0ec6782c1d135c693cb840c6a2116c0fa5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183163
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-03-27 05:25:43 +01:00
varshneydevansh 2a20616d09 Move Windows error helpers to comphelper namespace
Previously, WindowsErrorString and WindowsErrorStringFromHRESULT were
defined in an anonymous namespace in windowserrorstring.hxx, which:
1. Made them unavailable to other translation units
2. Violate ODR by creating separate copies in each TU
3. Require workarounds to access them

Changes:
- Move functions to proper comphelper namespace
- Keep implementations inline as they're simple utilities
- Preserve all existing functionality
- Update all call sites to use comphelper:: prefix

This change enables proper use of these utilities across LibreOffice
while maintaining current behavior and performance characteristics.

Introduced in this commit:

    commit 94cdcaa4d8
    Author: Tor Lillqvist <tml@collabora.com>
    Date:   Thu Aug 13 13:22:28 2015 +0300

        Add a globally usable WindowsErrorString function

Change-Id: I34df1c2b1f30c6204f107ca4792131d692203880
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183332
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2025-03-26 15:11:33 +01:00
Akshay Kumar Dubey 12d487285b tdf#42982 Improve UNO API error reporting
Change-Id: I35b815e45debc479d20c956fd07a188d0251853d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181293
Tested-by: Jenkins
Reviewed-by: Hossein   <hossein@libreoffice.org>
2025-02-19 08:29:06 +01:00
Caolán McNamara 836d73a651 consider VndSunStarExpand an exotic protocol
and generally don't bother with it when fetching data
from urls

Change-Id: I51a2601c6fb7d6c32f9e2d1286ee0d3b05b370b9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176645
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
2024-11-19 20:20:03 +01:00
Caolán McNamara 7bbe74b2be cid#1555789 COPY_INSTEAD_OF_MOVE
and

cid#1556865 COPY_INSTEAD_OF_MOVE
cid#1556871 COPY_INSTEAD_OF_MOVE
cid#1556939 COPY_INSTEAD_OF_MOVE
cid#1556951 COPY_INSTEAD_OF_MOVE
cid#1556964 COPY_INSTEAD_OF_MOVE
cid#1556966 COPY_INSTEAD_OF_MOVE
cid#1556968 COPY_INSTEAD_OF_MOVE
cid#1556971 COPY_INSTEAD_OF_MOVE
cid#1556989 COPY_INSTEAD_OF_MOVE
cid#1557001 COPY_INSTEAD_OF_MOVE
cid#1557011 COPY_INSTEAD_OF_MOVE
cid#1557032 COPY_INSTEAD_OF_MOVE
cid#1557038 COPY_INSTEAD_OF_MOVE
cid#1557041 COPY_INSTEAD_OF_MOVE
cid#1557055 COPY_INSTEAD_OF_MOVE
cid#1557056 COPY_INSTEAD_OF_MOVE
cid#1557057 COPY_INSTEAD_OF_MOVE
cid#1557065 COPY_INSTEAD_OF_MOVE
cid#1557068 COPY_INSTEAD_OF_MOVE
cid#1557087 COPY_INSTEAD_OF_MOVE
cid#1557090 COPY_INSTEAD_OF_MOVE
cid#1557093 COPY_INSTEAD_OF_MOVE
cid#1557113 COPY_INSTEAD_OF_MOVE
cid#1557122 COPY_INSTEAD_OF_MOVE
cid#1557126 COPY_INSTEAD_OF_MOVE
cid#1557145 COPY_INSTEAD_OF_MOVE
cid#1557151 COPY_INSTEAD_OF_MOVE
cid#1557152 COPY_INSTEAD_OF_MOVE
cid#1557197 COPY_INSTEAD_OF_MOVE
cid#1557216 COPY_INSTEAD_OF_MOVE
cid#1557245 COPY_INSTEAD_OF_MOVE
cid#1557272 COPY_INSTEAD_OF_MOVE
cid#1557310 COPY_INSTEAD_OF_MOVE
cid#1557314 COPY_INSTEAD_OF_MOVE
cid#1557318 COPY_INSTEAD_OF_MOVE
cid#1557333 COPY_INSTEAD_OF_MOVE
cid#1557340 COPY_INSTEAD_OF_MOVE
cid#1557358 COPY_INSTEAD_OF_MOVE
cid#1557359 COPY_INSTEAD_OF_MOVE
cid#1557365 COPY_INSTEAD_OF_MOVE
cid#1557367 COPY_INSTEAD_OF_MOVE
cid#1557395 COPY_INSTEAD_OF_MOVE
cid#1557418 COPY_INSTEAD_OF_MOVE
cid#1557488 COPY_INSTEAD_OF_MOVE
cid#1557493 COPY_INSTEAD_OF_MOVE
cid#1557506 COPY_INSTEAD_OF_MOVE
cid#1557514 COPY_INSTEAD_OF_MOVE
cid#1557528 COPY_INSTEAD_OF_MOVE
cid#1557534 COPY_INSTEAD_OF_MOVE
cid#1557537 COPY_INSTEAD_OF_MOVE
cid#1557562 COPY_INSTEAD_OF_MOVE
cid#1557563 COPY_INSTEAD_OF_MOVE
cid#1557592 COPY_INSTEAD_OF_MOVE
cid#1557608 COPY_INSTEAD_OF_MOVE
cid#1557615 COPY_INSTEAD_OF_MOVE
cid#1557619 COPY_INSTEAD_OF_MOVE
cid#1557637 COPY_INSTEAD_OF_MOVE
cid#1557648 COPY_INSTEAD_OF_MOVE
cid#1557712 COPY_INSTEAD_OF_MOVE
cid#1557750 COPY_INSTEAD_OF_MOVE
cid#1557762 COPY_INSTEAD_OF_MOVE
cid#1557765 COPY_INSTEAD_OF_MOVE

Change-Id: I10db1910627e04a26e25836c05ad5c2707abd18b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175696
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
2024-10-27 20:19:12 +01:00
Caolán McNamara 7cf8cffcb8 cid#1633347 COPY_INSTEAD_OF_MOVE
and

cid#1633346 COPY_INSTEAD_OF_MOVE
cid#1633344 COPY_INSTEAD_OF_MOVE
cid#1633343 COPY_INSTEAD_OF_MOVE
cid#1633340 COPY_INSTEAD_OF_MOVE
cid#1608137 COPY_INSTEAD_OF_MOVE
cid#1608131 COPY_INSTEAD_OF_MOVE
cid#1607860 COPY_INSTEAD_OF_MOVE
cid#1607432 COPY_INSTEAD_OF_MOVE
cid#1607394 COPY_INSTEAD_OF_MOVE
cid#1607310 COPY_INSTEAD_OF_MOVE
cid#1607156 COPY_INSTEAD_OF_MOVE
cid#1607093 COPY_INSTEAD_OF_MOVE
cid#1607090 COPY_INSTEAD_OF_MOVE
cid#1607039 COPY_INSTEAD_OF_MOVE
cid#1606709 COPY_INSTEAD_OF_MOVE
cid#1558053 COPY_INSTEAD_OF_MOVE
cid#1558052 COPY_INSTEAD_OF_MOVE
cid#1558042 COPY_INSTEAD_OF_MOVE
cid#1558038 COPY_INSTEAD_OF_MOVE
cid#1558037 COPY_INSTEAD_OF_MOVE
cid#1558034 COPY_INSTEAD_OF_MOVE
cid#1558031 COPY_INSTEAD_OF_MOVE
cid#1558027 COPY_INSTEAD_OF_MOVE
cid#1557994 COPY_INSTEAD_OF_MOVE
cid#1557977 COPY_INSTEAD_OF_MOVE
cid#1557970 COPY_INSTEAD_OF_MOVE
cid#1557966 COPY_INSTEAD_OF_MOVE
cid#1557957 COPY_INSTEAD_OF_MOVE
cid#1557954 COPY_INSTEAD_OF_MOVE
cid#1557941 COPY_INSTEAD_OF_MOVE
cid#1557933 COPY_INSTEAD_OF_MOVE
cid#1557918 COPY_INSTEAD_OF_MOVE
cid#1557907 COPY_INSTEAD_OF_MOVE
cid#1557890 COPY_INSTEAD_OF_MOVE
cid#1557883 COPY_INSTEAD_OF_MOVE
cid#1557881 COPY_INSTEAD_OF_MOVE
cid#1557861 COPY_INSTEAD_OF_MOVE
cid#1557842 COPY_INSTEAD_OF_MOVE
cid#1557840 COPY_INSTEAD_OF_MOVE
cid#1557830 COPY_INSTEAD_OF_MOVE
cid#1557830 COPY_INSTEAD_OF_MOVE

Change-Id: If5ee3396eafdb8b338d9e6cf0705be6e2b431fd5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175577
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-10-25 10:48:12 +02:00
Mike Kaganski f2808f9165 Avoid deadlock
As seen in the following call stacks:

Main thread

  sal3!osl_acquireMutex+0x49 [libre-office-git-repo\sal\osl\w32\mutex.cxx @ 65]
  emboleobj!osl::Mutex::acquire+0x9 [libre-office-git-repo\include\osl\mutex.hxx @ 63]
  emboleobj!osl::ClearableGuard<osl::Mutex>::{ctor}+0xd [libre-office-git-repo\include\osl\mutex.hxx @ 182]
  emboleobj!osl::ResettableGuard<osl::Mutex>::{ctor}+0xd [libre-office-git-repo\include\osl\mutex.hxx @ 236]
  emboleobj!OleEmbeddedObject::getStatus+0x72 [libre-office-git-repo\embeddedobj\source\msole\oleembed.cxx @ 1133]
  sfxlo!SfxViewShell::CheckIPClient_Impl+0x42 [libre-office-git-repo\sfx2\source\view\viewsh.cxx @ 3563]
  sfxlo!SfxInPlaceClient_Impl::TimerHdl+0x40 [libre-office-git-repo\sfx2\source\view\ipclient.cxx @ 628]
  sfxlo!SfxInPlaceClient_Impl::LinkStubTimerHdl+0x53 [libre-office-git-repo\sfx2\source\view\ipclient.cxx @ 624]
  vcllo!Scheduler::CallbackTaskScheduling+0x130e [libre-office-git-repo\vcl\source\app\scheduler.cxx @ 511]
  vclplug_winlo!WinSalTimer::ImplHandleElapsedTimer+0x2e [libre-office-git-repo\vcl\win\app\saltimer.cxx @ 167]
  vclplug_winlo!ImplSalYield+0x14f [libre-office-git-repo\vcl\win\app\salinst.cxx @ 525]
  vclplug_winlo!WinSalInstance::DoYield+0xad [libre-office-git-repo\vcl\win\app\salinst.cxx @ 581]
  vcllo!ImplYield+0x367 [libre-office-git-repo\vcl\source\app\svapp.cxx @ 393]
  vcllo!Application::Execute+0xfa [libre-office-git-repo\vcl\source\app\svapp.cxx @ 369]
  sofficeapp!desktop::Desktop::Main+0x173f [libre-office-git-repo\desktop\source\app\app.cxx @ 1605]
  vcllo!ImplSVMain+0xda [libre-office-git-repo\vcl\source\app\svmain.cxx @ 229]
  sofficeapp!soffice_main+0xf3 [libre-office-git-repo\desktop\source\app\sofficemain.cxx @ 94]

Request thread

  sal3!osl_acquireMutex+0x49 [libre-office-git-repo\sal\osl\w32\mutex.cxx @ 65]
  vclplug_winlo!osl::Mutex::acquire+0xa [libre-office-git-repo\include\osl\mutex.hxx @ 63]
  vclplug_winlo!SalYieldMutex::doAcquire+0x91 [libre-office-git-repo\vcl\win\app\salinst.cxx @ 148]
  emboleobj!SolarMutexReleaser::{dtor}+0xc [libre-office-git-repo\include\vcl\svapp.hxx @ 1425]
  emboleobj!OleComponent::StoreOwnTmpIfNecessary+0x1d3 [libre-office-git-repo\embeddedobj\source\msole\olecomponent.cxx @ 1365]
  emboleobj!OleEmbeddedObject::StoreObjectToStream+0x2f [libre-office-git-repo\embeddedobj\source\msole\olepersist.cxx @ 1032]
  emboleobj!OleEmbeddedObject::StoreToLocation_Impl+0x3cc [libre-office-git-repo\embeddedobj\source\msole\olepersist.cxx @ 1169]
  emboleobj!OleEmbeddedObject::storeAsEntry+0x152 [libre-office-git-repo\embeddedobj\source\msole\olepersist.cxx @ 1523]
  comphelper!comphelper::EmbeddedObjectContainer::StoreEmbeddedObject+0x490 [libre-office-git-repo\comphelper\source\container\embeddedobjectcontainer.cxx @ 501]
  comphelper!comphelper::EmbeddedObjectContainer::InsertEmbeddedObject+0x6f [libre-office-git-repo\comphelper\source\container\embeddedobjectcontainer.cxx @ 518]
  comphelper!comphelper::EmbeddedObjectContainer::RemoveEmbeddedObject+0x388 [libre-office-git-repo\comphelper\source\container\embeddedobjectcontainer.cxx @ 945]
  comphelper!comphelper::EmbeddedObjectContainer::RemoveEmbeddedObject+0x46 [libre-office-git-repo\comphelper\source\container\embeddedobjectcontainer.cxx @ 831]
  swlo!SwOLENode::SavePersistentData+0x20b [libre-office-git-repo\sw\source\core\ole\ndole.cxx @ 403]
  swlo!SwNodes::ChgNode+0x411 [libre-office-git-repo\sw\source\core\docnode\nodes.cxx @ 214]
  swlo!SwNodes::MoveNodes+0x18e6 [libre-office-git-repo\sw\source\core\docnode\nodes.cxx @ 868]
  swlo!SwUndoSaveContent::MoveToUndoNds+0x1c1 [libre-office-git-repo\sw\source\core\undo\undobj.cxx @ 784]
  swlo!SwUndoSaveSection::SaveSection+0x559 [libre-office-git-repo\sw\source\core\undo\undobj.cxx @ 1325]
  swlo!SwUndoSaveSection::SaveSection+0x55 [libre-office-git-repo\sw\source\core\undo\undobj.cxx @ 1278]
  swlo!SwUndoFlyBase::DelFly+0x127 [libre-office-git-repo\sw\source\core\undo\undobj1.cxx @ 232]
  swlo!SwUndoDelLayFormat::SwUndoDelLayFormat+0x64 [libre-office-git-repo\sw\source\core\undo\undobj1.cxx @ 429]
  swlo!std::make_unique+0x22 [C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\memory @ 3382]
  swlo!sw::DocumentLayoutManager::DelLayoutFormat+0x283 [libre-office-git-repo\sw\source\core\doc\DocumentLayoutManager.cxx @ 242]
  swlo!SwTextNode::DestroyAttr+0x82 [libre-office-git-repo\sw\source\core\txtnode\thints.cxx @ 1204]
  swlo!SwTextNode::EraseText+0x18f [libre-office-git-repo\sw\source\core\txtnode\ndtxt.cxx @ 2813]
  swlo!SwTextNode::DeleteAttributes+0x115 [libre-office-git-repo\sw\source\core\txtnode\thints.cxx @ 1863]
  swlo!SwXFrame::dispose+0xdb [libre-office-git-repo\sw\source\core\unocore\unoframe.cxx @ 2692]
  mscx_uno!`anonymous namespace'::cpp_call+0x710 [libre-office-git-repo\bridges\source\cpp_uno\msvc_win32_x86-64\uno2cpp.cxx @ 214]
  mscx_uno!unoInterfaceProxyDispatch+0x2fa [libre-office-git-repo\bridges\source\cpp_uno\msvc_win32_x86-64\uno2cpp.cxx @ 430]
  binaryurplo!binaryurp::IncomingRequest::execute_throw+0x635 [libre-office-git-repo\binaryurp\source\incomingrequest.cxx @ 239]
  binaryurplo!binaryurp::IncomingRequest::execute+0xbf [libre-office-git-repo\binaryurp\source\incomingrequest.cxx @ 79]
  binaryurplo!request+0x1c [libre-office-git-repo\binaryurp\source\reader.cxx @ 84]
  cppu3!cppu_threadpool::JobQueue::enter+0x21e [libre-office-git-repo\cppu\source\threadpool\jobqueue.cxx @ 101]
  cppu3!cppu_threadpool::ORequestThread::run+0xa0 [libre-office-git-repo\cppu\source\threadpool\thread.cxx @ 169]

where the call to OleComponent::StoreOwnTmpIfNecessary from
OleEmbeddedObject::StoreObjectToStream was made with m_aMutex
held; and that mutex was attempted to be locked from the main
thread, holding solar mutex.

Change-Id: I1914188728cdaa9cdf22d216ec71f733d7780692
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175117
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2024-10-18 11:14:16 +02:00
Mike Kaganski 7122fcf862 Avoid deadlock because of recursive lock
As seen in the following call stacks:

Main thread

  sal3!osl_acquireMutex+0x49 [libre-office-git-repo\sal\osl\w32\mutex.cxx @ 65]
  emboleobj!osl::Mutex::acquire+0x9 [libre-office-git-repo\include\osl\mutex.hxx @ 63]
  emboleobj!osl::Guard<osl::Mutex>::{ctor}+0x9 [libre-office-git-repo\include\osl\mutex.hxx @ 144]
  emboleobj!OleEmbeddedObject::getCurrentState+0x68 [libre-office-git-repo\embeddedobj\source\msole\oleembed.cxx @ 643]
  sfxlo!SfxInPlaceClient::IsObjectUIActive+0x23 [libre-office-git-repo\sfx2\source\view\ipclient.cxx @ 847]
  sfxlo!SfxViewShell::GetUIActiveClient+0x5b [libre-office-git-repo\sfx2\source\view\viewsh.cxx @ 2521]
  sfxlo!SfxDispatcher::FindServer_+0x282 [libre-office-git-repo\sfx2\source\control\dispatch.cxx @ 1627]
  sfxlo!SfxDispatcher::GetShellAndSlot_Impl+0x2f [libre-office-git-repo\sfx2\source\control\dispatch.cxx @ 703]
  sfxlo!SfxDispatcher::QueryState+0x5b [libre-office-git-repo\sfx2\source\control\dispatch.cxx @ 1979]
  swlo!SwView::CheckReadonlyState+0x64 [libre-office-git-repo\sw\source\uibase\uiview\view.cxx @ 627]
  swlo!SwView::TimeoutHdl+0x76 [libre-office-git-repo\sw\source\uibase\uiview\view.cxx @ 608]
  vcllo!Scheduler::CallbackTaskScheduling+0x130e [libre-office-git-repo\vcl\source\app\scheduler.cxx @ 511]
  vclplug_winlo!WinSalTimer::ImplHandleElapsedTimer+0x2e [libre-office-git-repo\vcl\win\app\saltimer.cxx @ 167]
  vclplug_winlo!ImplSalYield+0x14f [libre-office-git-repo\vcl\win\app\salinst.cxx @ 525]
  vclplug_winlo!WinSalInstance::DoYield+0xad [libre-office-git-repo\vcl\win\app\salinst.cxx @ 581]
  vcllo!ImplYield+0x367 [libre-office-git-repo\vcl\source\app\svapp.cxx @ 393]
  vcllo!Application::Execute+0xfa [libre-office-git-repo\vcl\source\app\svapp.cxx @ 369]
  sofficeapp!desktop::Desktop::Main+0x173f [libre-office-git-repo\desktop\source\app\app.cxx @ 1605]
  vcllo!ImplSVMain+0xda [libre-office-git-repo\vcl\source\app\svmain.cxx @ 229]
  sofficeapp!soffice_main+0xf3 [libre-office-git-repo\desktop\source\app\sofficemain.cxx @ 94]

Request thread

  sal3!osl_acquireMutex+0x49 [libre-office-git-repo\sal\osl\w32\mutex.cxx @ 65]
  vclplug_winlo!osl::Mutex::acquire+0xa [libre-office-git-repo\include\osl\mutex.hxx @ 63]
  vclplug_winlo!SalYieldMutex::doAcquire+0x91 [libre-office-git-repo\vcl\win\app\salinst.cxx @ 148]
  emboleobj!SolarMutexReleaser::{dtor}+0xc [libre-office-git-repo\include\vcl\svapp.hxx @ 1425]
  emboleobj!OleComponent::GetExtent+0x102 [libre-office-git-repo\embeddedobj\source\msole\olecomponent.cxx @ 1134]
  emboleobj!OleEmbeddedObject::getVisualAreaSize+0x23f [libre-office-git-repo\embeddedobj\source\msole\olevisual.cxx @ 227]
  emboleobj!OleEmbeddedObject::saveCompleted+0x406 [libre-office-git-repo\embeddedobj\source\msole\olepersist.cxx @ 1603]
  comphelper!comphelper::EmbeddedObjectContainer::StoreEmbeddedObject+0x49b [libre-office-git-repo\comphelper\source\container\embeddedobjectcontainer.cxx @ 501]
  comphelper!comphelper::EmbeddedObjectContainer::InsertEmbeddedObject+0x6f [libre-office-git-repo\comphelper\source\container\embeddedobjectcontainer.cxx @ 518]
  comphelper!comphelper::EmbeddedObjectContainer::RemoveEmbeddedObject+0x388 [libre-office-git-repo\comphelper\source\container\embeddedobjectcontainer.cxx @ 945]
  comphelper!comphelper::EmbeddedObjectContainer::RemoveEmbeddedObject+0x46 [libre-office-git-repo\comphelper\source\container\embeddedobjectcontainer.cxx @ 831]
  swlo!SwOLENode::SavePersistentData+0x20b [libre-office-git-repo\sw\source\core\ole\ndole.cxx @ 403]
  swlo!SwNodes::ChgNode+0x411 [libre-office-git-repo\sw\source\core\docnode\nodes.cxx @ 214]
  swlo!SwNodes::MoveNodes+0x18e6 [libre-office-git-repo\sw\source\core\docnode\nodes.cxx @ 868]
  swlo!SwUndoSaveContent::MoveToUndoNds+0x1c1 [libre-office-git-repo\sw\source\core\undo\undobj.cxx @ 784]
  swlo!SwUndoSaveSection::SaveSection+0x559 [libre-office-git-repo\sw\source\core\undo\undobj.cxx @ 1325]
  swlo!SwUndoSaveSection::SaveSection+0x55 [libre-office-git-repo\sw\source\core\undo\undobj.cxx @ 1278]
  swlo!SwUndoFlyBase::DelFly+0x127 [libre-office-git-repo\sw\source\core\undo\undobj1.cxx @ 232]
  swlo!SwUndoDelLayFormat::SwUndoDelLayFormat+0x64 [libre-office-git-repo\sw\source\core\undo\undobj1.cxx @ 429]
  swlo!std::make_unique+0x22 [C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\memory @ 3382]
  swlo!sw::DocumentLayoutManager::DelLayoutFormat+0x283 [libre-office-git-repo\sw\source\core\doc\DocumentLayoutManager.cxx @ 242]
  swlo!SwTextNode::DestroyAttr+0x82 [libre-office-git-repo\sw\source\core\txtnode\thints.cxx @ 1204]
  swlo!SwTextNode::EraseText+0x18f [libre-office-git-repo\sw\source\core\txtnode\ndtxt.cxx @ 2813]
  swlo!SwTextNode::DeleteAttributes+0x115 [libre-office-git-repo\sw\source\core\txtnode\thints.cxx @ 1863]
  swlo!SwXFrame::dispose+0xdb [libre-office-git-repo\sw\source\core\unocore\unoframe.cxx @ 2692]
  mscx_uno!`anonymous namespace'::cpp_call+0x710 [libre-office-git-repo\bridges\source\cpp_uno\msvc_win32_x86-64\uno2cpp.cxx @ 214]
  mscx_uno!unoInterfaceProxyDispatch+0x2fa [libre-office-git-repo\bridges\source\cpp_uno\msvc_win32_x86-64\uno2cpp.cxx @ 430]
  binaryurplo!binaryurp::IncomingRequest::execute_throw+0x635 [libre-office-git-repo\binaryurp\source\incomingrequest.cxx @ 239]
  binaryurplo!binaryurp::IncomingRequest::execute+0xbf [libre-office-git-repo\binaryurp\source\incomingrequest.cxx @ 79]
  binaryurplo!request+0x1c [libre-office-git-repo\binaryurp\source\reader.cxx @ 84]
  cppu3!cppu_threadpool::JobQueue::enter+0x21e [libre-office-git-repo\cppu\source\threadpool\jobqueue.cxx @ 101]
  cppu3!cppu_threadpool::ORequestThread::run+0xa0 [libre-office-git-repo\cppu\source\threadpool\thread.cxx @ 169]

As seen, the request thread has OleEmbeddedObject::saveCompleted
and OleEmbeddedObject::getVisualAreaSize on the stack; both acquire
OleEmbeddedObject's mutex; but only getVisualAreaSize releases it
for the call of OleComponent::GetExtent. The latter releases solar
mutex, at which time, the main thread (locking the solar mutex)
attempts to call OleEmbeddedObject::getCurrentState, which needs
the object's mutex, which is still locked in the request thread.

Avoid this, by passing the lock object to the implementation of
getVisualAreaSize from saveCompleted.

Change-Id: Ie44a20a8c89000e0e951e024c2bfde93cf2cc3f6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174891
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-10-14 21:18:05 +02:00
Mike Kaganski 47d8d0cbe7 Avoid deadlock
Seen when running an external Java code, with these call stacks:

Main thread:

 win32u.dll!NtUserMsgWaitForMultipleObjectsEx()
 sal3.dll!osl_waitCondition(void * Condition, const TimeValue * pTimeout)
 [Inline Frame] vclplug_winlo.dll!osl::Condition::wait(const TimeValue *)
 vclplug_winlo.dll!SalYieldMutex::doAcquire(unsigned long nLockCount)
 [Inline Frame] emboleobj.dll!SolarMutexReleaser::{dtor}()
 emboleobj.dll!OleComponent::getTransferData(const com::sun::star::datatransfer::DataFlavor & aFlavor)
 emboleobj.dll!OleEmbeddedObject::getPreferredVisualRepresentation(__int64 nAspect)
 comphelper.dll!comphelper::EmbeddedObjectContainer::GetGraphicReplacementStream(__int64 nViewAspect, const com::sun::star::uno::Reference<com::sun::star::embed::XEmbeddedObject> & xObj, rtl::OUString * pMediaType)
 [Inline Frame] svtlo.dll!svt::EmbeddedObjectRef::GetGraphicReplacementStream(__int64)
 svtlo.dll!svt::EmbeddedObjectRef::GetGraphicStream(bool bUpdate)
 svtlo.dll!svt::EmbeddedObjectRef::GetReplacement(bool bUpdate)
 svtlo.dll!svt::EmbeddedObjectRef::UpdateReplacement(bool bUpdateOle)
 swlo.dll!SwWrtShell::CalcAndSetScale(svt::EmbeddedObjectRef & xObj, const SwRect * pFlyPrtRect, const SwRect * pFlyFrameRect, const bool bNoTextFramePrtAreaChanged)
 swlo.dll!SwContentNotify::ImplDestroy()
 swlo.dll!SwContentNotify::~SwContentNotify()
 swlo.dll!SwNoTextFrame::MakeAll(OutputDevice * pRenderContext)
 swlo.dll!SwFrame::OptPrepareMake()
 [Inline Frame] swlo.dll!SwFrame::OptCalc()
 swlo.dll!SwLayAction::FormatContent_(const SwContentFrame * pContent, const SwPageFrame * pPage)
 swlo.dll!SwLayAction::FormatFlyContent(const SwFlyFrame * pFly)
 swlo.dll!SwObjectFormatter::FormatObj_(SwAnchoredObject & _rAnchoredObj)
 swlo.dll!SwObjectFormatterTextFrame::DoFormatObj(SwAnchoredObject & _rAnchoredObj, const bool _bCheckForMovedFwd)
 swlo.dll!SwObjectFormatter::FormatObjsAtFrame_(SwTextFrame * _pMasterTextFrame)
 swlo.dll!SwObjectFormatterTextFrame::DoFormatObjs()
 swlo.dll!SwObjectFormatter::FormatObjsAtFrame(SwFrame & _rAnchorFrame, const SwPageFrame & _rPageFrame, SwLayAction * _pLayAction)
 swlo.dll!SwLayAction::FormatContent(SwPageFrame * pPage)
 swlo.dll!SwLayAction::InternalAction(OutputDevice * pRenderContext)
 [Inline Frame] swlo.dll!SwLayAction::Action(OutputDevice * pRenderContext)
 swlo.dll!SwLayIdle::SwLayIdle(SwRootFrame * pRt, SwViewShellImp * pI)
 swlo.dll!SwViewShell::LayoutIdle()
 swlo.dll!sw::DocumentTimerManager::DoIdleJobs(Timer * __formal)
 vcllo.dll!Scheduler::CallbackTaskScheduling()
 vclplug_winlo.dll!WinSalTimer::ImplHandleElapsedTimer()
 vclplug_winlo.dll!ImplSalYield(bool bWait, bool bHandleAllCurrentEvents)
 vclplug_winlo.dll!WinSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents)
 vcllo.dll!ImplYield(bool i_bWait, bool i_bAllEvents)
 vcllo.dll!Application::Execute()
 sofficeapp.dll!desktop::Desktop::Main()
 vcllo.dll!ImplSVMain()
 sofficeapp.dll!soffice_main()
 [Inline Frame] soffice.bin!sal_main()
 soffice.bin!main(int argc, char * * argv)
 [Inline Frame] soffice.bin!invoke_main()
 soffice.bin!__scrt_common_main_seh()
 kernel32.dll!BaseThreadInitThunk()
 ntdll.dll!RtlUserThreadStart()

Request thread:

 ntdll.dll!NtWaitForAlertByThreadId()
 ntdll.dll!RtlpWaitOnCriticalSection()
 ntdll.dll!RtlpEnterCriticalSectionContended()
 ntdll.dll!RtlEnterCriticalSection()
 sal3.dll!osl_acquireMutex(_oslMutexImpl * Mutex)
 [Inline Frame] emboleobj.dll!osl::Mutex::acquire()
 [Inline Frame] emboleobj.dll!osl::Guard<osl::Mutex>::{ctor}(osl::Mutex &)
 emboleobj.dll!OleComponent::addModifyListener(const com::sun::star::uno::Reference<com::sun::star::util::XModifyListener> & xListener)
 svtlo.dll!svt::`anonymous namespace'::EmbedEventListener_Impl::Create(svt::EmbeddedObjectRef * p)
 svtlo.dll!svt::EmbeddedObjectRef::EmbeddedObjectRef(const com::sun::star::uno::Reference<com::sun::star::embed::XEmbeddedObject> & xObj, __int64 nAspect)
 swlo.dll!SwXFrame::getPropertyValue(const rtl::OUString & rPropertyName)
 mscx_uno.dll!`anonymous namespace'::cpp_call(bridges::cpp_uno::shared::UnoInterfaceProxy * pThis, bridges::cpp_uno::shared::VtableSlot aVtableSlot, _typelib_TypeDescriptionReference * pReturnTypeRef, long nParams, _typelib_MethodParameter * pParams, void * pUnoReturn, void * * pUnoArgs, _uno_Any * * ppUnoExc)
 mscx_uno.dll!unoInterfaceProxyDispatch(_uno_Interface * pUnoI, const _typelib_TypeDescription * pMemberTD, void * pReturn, void * * pArgs, _uno_Any * * ppException)
 binaryurplo.dll!binaryurp::IncomingRequest::execute_throw(binaryurp::BinaryAny * returnValue, std::vector<binaryurp::BinaryAny,std::allocator<binaryurp::BinaryAny>> * outArguments)
 binaryurplo.dll!binaryurp::IncomingRequest::execute()
 binaryurplo.dll!request(void * pThreadSpecificData)
 cppu3.dll!cppu_threadpool::JobQueue::enter(const void * nDisposeId, bool bReturnWhenNoJob)
 cppu3.dll!cppu_threadpool::ORequestThread::run()
 cppu3.dll!threadFunc(void * param)
 sal3.dll!oslWorkerWrapperFunction(void * pData)
 ucrtbase.dll!thread_start<unsigned int (__cdecl*)(void *),1>()
 kernel32.dll!BaseThreadInitThunk()
 ntdll.dll!RtlUserThreadStart()

Change-Id: I54d3fd91d8bbf4f52eee2f498c91e06ebc82d836
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172864
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2024-09-04 16:56:07 +02:00
Mike Kaganski 6084a2904d Make OleEmbeddedObject locking stricter
This is an attempt to reduce areas that execute with mutex unlocked
because the called code may deadlock. Also, this copies objects on
stack before unlocking, using lambdas' own variables.

I hope that it somewhat improves reliability. OTOH, this runs more
code with lock active, has a potential of new deadlocks, so risky.

Change-Id: I558b7f5f18f63622fed3a9c3978327d0d76fe90d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172237
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-08-22 12:06:43 +02:00
Mike Kaganski 53ac9e0f3c Make OleEmbeddedObject::GetRidOfComponent safer when releasing lock
Thanks Michael Stahl for the useful advise - see
https://gerrit.libreoffice.org/c/core/+/171996/comment/4dc20148_5ec861ad/

Change-Id: I16e1876a81a52f291ede49572f012c15d4cd9a6d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172233
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-08-22 08:22:49 +02:00
Mike Kaganski 29f59dad0e Unlock the mutex to avoid deadlock
The request thread was calling OleComponent::CloseObject, which executed
on main thread; OleEmbeddedObject::m_aMutex as locked by request thread:

 emboleobj.dll!OleComponent::CloseObject() Line 1004
 emboleobj.dll!OleComponent::Dispose() Line 451
 emboleobj.dll!OleComponent::close(unsigned char bDeliverOwnership) Line 1513
 emboleobj.dll!OleEmbeddedObject::GetRidOfComponent() Line 235
 emboleobj.dll!OleEmbeddedObject::Dispose() Line 269
 emboleobj.dll!OleEmbeddedObject::close(unsigned char bDeliverOwnership) Line 498
 comphelper.dll!comphelper::EmbeddedObjectContainer::CloseEmbeddedObjects() Line 208
 sfxlo.dll!SfxObjectShell::~SfxObjectShell() Line 322
 swlo.dll!SwDocShell::~SwDocShell() Line 380
 swlo.dll!SwDocShell::`vector deleting destructor'(unsigned int)
 cppuhelper3MSC.dll!cppu::OWeakObject::release() Line 229
 sfxlo.dll!rtl::Reference<SfxObjectShell>::~Reference<SfxObjectShell>() Line 126
 sfxlo.dll!IMPL_SfxBaseModel_DataContainer::~IMPL_SfxBaseModel_DataContainer() Line 265
 sfxlo.dll!IMPL_SfxBaseModel_DataContainer::`scalar deleting destructor'(unsigned int)
 sfxlo.dll!std::_Destroy_in_place<IMPL_SfxBaseModel_DataContainer>(IMPL_SfxBaseModel_DataContainer & _Obj) Line 293
 sfxlo.dll!std::_Ref_count_obj2<IMPL_SfxBaseModel_DataContainer>::_Destroy() Line 2113
 sfxlo.dll!std::_Ref_count_base::_Decref() Line 1164
 sfxlo.dll!std::_Ptr_base<IMPL_SfxBaseModel_DataContainer>::_Decref() Line 1380
 sfxlo.dll!std::shared_ptr<IMPL_SfxBaseModel_DataContainer>::~shared_ptr<IMPL_SfxBaseModel_DataContainer>() Line 1685
 sfxlo.dll!std::shared_ptr<IMPL_SfxBaseModel_DataContainer>::reset() Line 1732
 sfxlo.dll!SfxBaseModel::dispose() Line 794
 swlo.dll!SwXTextDocument::dispose() Line 561
 sfxlo.dll!SfxBaseModel::close(unsigned char bDeliverOwnership) Line 1523
 swlo.dll!SwXTextDocument::close(unsigned char bDeliverOwnership) Line 574
 sfxlo.dll!SfxBaseModel::dispose() Line 745
 swlo.dll!SwXTextDocument::dispose() Line 561
 mscx_uno.dll!`anonymous namespace'::cpp_call(bridges::cpp_uno::shared::UnoInterfaceProxy * pThis, bridges::cpp_uno::shared::VtableSlot aVtableSlot, _typelib_TypeDescriptionReference * pReturnTypeRef, long nParams, _typelib_MethodParameter * pParams, void * pUnoReturn, void * * pUnoArgs, _uno_Any * * ppUnoExc) Line 214
 mscx_uno.dll!unoInterfaceProxyDispatch(_uno_Interface * pUnoI, const _typelib_TypeDescription * pMemberTD, void * pReturn, void * * pArgs, _uno_Any * * ppException) Line 430
 binaryurplo.dll!binaryurp::IncomingRequest::execute_throw(binaryurp::BinaryAny * returnValue, std::vector<binaryurp::BinaryAny,std::allocator<binaryurp::BinaryAny>> * outArguments) Line 239
 binaryurplo.dll!binaryurp::IncomingRequest::execute() Line 79
 binaryurplo.dll!request(void * pThreadSpecificData) Line 84
 cppu3.dll!cppu_threadpool::JobQueue::enter(const void * nDisposeId, bool bReturnWhenNoJob) Line 101
 cppu3.dll!cppu_threadpool::ORequestThread::run() Line 165
 cppu3.dll!threadFunc(void * param) Line 190
 sal3.dll!oslWorkerWrapperFunction(void * pData) Line 67

Main thread was acquiring OleEmbeddedObject::m_aMutex, which deadlocked:

 sal3.dll!osl_acquireMutex(_oslMutexImpl * Mutex) Line 65
 emboleobj.dll!osl::Mutex::acquire() Line 63
 emboleobj.dll!osl::ResettableGuard<osl::Mutex>::reset() Line 250
 emboleobj.dll!OleEmbeddedObject::setVisualAreaSize(__int64 nAspect, const com::sun::star::awt::Size & aSize) Line 148
 swlo.dll!SwWrtShell::CalcAndSetScale(svt::EmbeddedObjectRef & xObj, const SwRect * pFlyPrtRect, const SwRect * pFlyFrameRect, const bool bNoTextFramePrtAreaChanged) Line 777
 swlo.dll!SwContentNotify::ImplDestroy() Line 926
 swlo.dll!SwContentNotify::~SwContentNotify() Line 1037
 swlo.dll!SwNoTextFrame::MakeAll(OutputDevice * pRenderContext) Line 584
 swlo.dll!SwFrame::OptPrepareMake() Line 412
 swlo.dll!SwFrame::OptCalc() Line 1110
 swlo.dll!SwLayAction::FormatContent_(const SwContentFrame * pContent, const SwPageFrame * pPage) Line 1960
 swlo.dll!SwLayAction::FormatFlyContent(const SwFlyFrame * pFly) Line 1985
 swlo.dll!SwObjectFormatter::FormatObj_(SwAnchoredObject & _rAnchoredObj) Line 312
 swlo.dll!SwObjectFormatterTextFrame::DoFormatObj(SwAnchoredObject & _rAnchoredObj, const bool _bCheckForMovedFwd) Line 133
 swlo.dll!SwObjectFormatter::FormatObjsAtFrame_(SwTextFrame * _pMasterTextFrame) Line 414
 swlo.dll!SwObjectFormatterTextFrame::DoFormatObjs() Line 348
 swlo.dll!SwObjectFormatter::FormatObjsAtFrame(SwFrame & _rAnchorFrame, const SwPageFrame & _rPageFrame, SwLayAction * _pLayAction) Line 160
 swlo.dll!SwLayAction::FormatContent(SwPageFrame * pPage) Line 1793
 swlo.dll!SwLayAction::InternalAction(OutputDevice * pRenderContext) Line 605
 swlo.dll!SwLayAction::Action(OutputDevice * pRenderContext) Line 389
 swlo.dll!SwLayIdle::SwLayIdle(SwRootFrame * pRt, SwViewShellImp * pI) Line 2363
 swlo.dll!SwViewShell::LayoutIdle() Line 827
 swlo.dll!sw::DocumentTimerManager::DoIdleJobs(Timer * __formal) Line 176
 swlo.dll!sw::DocumentTimerManager::LinkStubDoIdleJobs(void * instance, Timer * data) Line 156
 vcllo.dll!Link<Timer *,void>::Call(Timer * data) Line 111
 vcllo.dll!Timer::Invoke() Line 75
 vcllo.dll!Scheduler::CallbackTaskScheduling() Line 509
 vcllo.dll!SalTimer::CallCallback() Line 53
 vclplug_winlo.dll!WinSalTimer::ImplHandleElapsedTimer() Line 169
 vclplug_winlo.dll!ImplSalYield(bool bWait, bool bHandleAllCurrentEvents) Line 525
 vclplug_winlo.dll!WinSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents) Line 581
 vcllo.dll!ImplYield(bool i_bWait, bool i_bAllEvents) Line 385
 vcllo.dll!Application::Yield() Line 473
 vcllo.dll!Application::Execute() Line 361
 sofficeapp.dll!desktop::Desktop::Main() Line 1652
 vcllo.dll!ImplSVMain() Line 229
 vcllo.dll!SVMain() Line 262
 sofficeapp.dll!soffice_main() Line 110
 soffice.bin!sal_main() Line 51
 soffice.bin!main(int argc, char * * argv) Line 49
 soffice.bin!invoke_main() Line 79
 soffice.bin!__scrt_common_main_seh() Line 288
 soffice.bin!__scrt_common_main() Line 331
 soffice.bin!mainCRTStartup(void * __formal) Line 17

Change-Id: Iaf5133c488d4f26f43530ea19584e99cce12d81e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171855
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-08-14 14:44:14 +02:00
Caolán McNamara d33d592801 cid#1554791 COPY_INSTEAD_OF_MOVE
and

cid#1554819 COPY_INSTEAD_OF_MOVE
cid#1554837 COPY_INSTEAD_OF_MOVE
cid#1554881 COPY_INSTEAD_OF_MOVE
cid#1554882 COPY_INSTEAD_OF_MOVE
cid#1554884 COPY_INSTEAD_OF_MOVE
cid#1554891 COPY_INSTEAD_OF_MOVE
cid#1554892 COPY_INSTEAD_OF_MOVE
cid#1554897 COPY_INSTEAD_OF_MOVE
cid#1554904 COPY_INSTEAD_OF_MOVE
cid#1554918 COPY_INSTEAD_OF_MOVE
cid#1554928 COPY_INSTEAD_OF_MOVE
cid#1554931 COPY_INSTEAD_OF_MOVE
cid#1554944 COPY_INSTEAD_OF_MOVE
cid#1554945 COPY_INSTEAD_OF_MOVE
cid#1554959 COPY_INSTEAD_OF_MOVE
cid#1554960 COPY_INSTEAD_OF_MOVE
cid#1554963 COPY_INSTEAD_OF_MOVE
cid#1554966 COPY_INSTEAD_OF_MOVE
cid#1554969 COPY_INSTEAD_OF_MOVE
cid#1554973 COPY_INSTEAD_OF_MOVE
cid#1555011 COPY_INSTEAD_OF_MOVE
cid#1555012 COPY_INSTEAD_OF_MOVE
cid#1555015 COPY_INSTEAD_OF_MOVE
cid#1555044 COPY_INSTEAD_OF_MOVE
cid#1555051 COPY_INSTEAD_OF_MOVE
cid#1555055 COPY_INSTEAD_OF_MOVE
cid#1555063 COPY_INSTEAD_OF_MOVE
cid#1555068 COPY_INSTEAD_OF_MOVE
cid#1555073 COPY_INSTEAD_OF_MOVE
cid#1555074 COPY_INSTEAD_OF_MOVE
cid#1555078 COPY_INSTEAD_OF_MOVE
cid#1555080 COPY_INSTEAD_OF_MOVE
cid#1555091 COPY_INSTEAD_OF_MOVE
cid#1555099 COPY_INSTEAD_OF_MOVE
cid#1555101 COPY_INSTEAD_OF_MOVE
cid#1555121 COPY_INSTEAD_OF_MOVE
cid#1610739 COPY_INSTEAD_OF_MOVE
cid#1608424 COPY_INSTEAD_OF_MOVE
cid#1608059 COPY_INSTEAD_OF_MOVE
cid#1607952 COPY_INSTEAD_OF_MOVE
cid#1607653 COPY_INSTEAD_OF_MOVE
cid#1607614 COPY_INSTEAD_OF_MOVE
cid#1607592 COPY_INSTEAD_OF_MOVE

Change-Id: Ie9f922a9fe1b8001dfab31e2741fe8bd5558e442
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170802
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-07-20 23:03:28 +02:00
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 a6a95c0ce4 cid#1608568 COPY_INSTEAD_OF_MOVE
Change-Id: I7509b0033855c66324d655b66bef9cc14f5e8074
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169980
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
2024-07-04 12:58:23 +02:00
Mike Kaganski d32153d321 Make sure to clear the guard around OleEmbeddedObject::changeState
The method itself clears its own guard; the caller still holding the
guard results in hangs seen in some Java code.

See also commit e2bfc34d14 (Reimplement
OleComponentNative_Impl to use IGlobalInterfaceTablem 2024-03-11).

Change-Id: Ib22e71e7500ccceb946f7b1d6606f8f61ae2afe8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169315
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2024-06-21 08:57:08 +02:00
Noel Grandin ddf32ef202 loplugin:ostr in embeddedobj
Change-Id: I644042d0ca6041174a8e11f780c546bcf7d4571a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167282
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2024-05-08 08:15:07 +02:00
Mike Kaganski 466156f14d Use osl::ResettableMutexGuardScopedReleaser instead of ad-hoc guards
Change-Id: I2aa09655c207d3647650b5e38011a600bd221699
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165777
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-04-04 13:21:14 +02:00
Mike Kaganski 328416e015 This assert was wrong
In commit e2bfc34d14 (Reimplement
OleComponentNative_Impl to use IGlobalInterfaceTable, 2024-03-11),
I added the assert in a false assumption that RunObject may only
be called once. Indeed, this is not so. Thus just make sure to not
try to register it second time.

Change-Id: I36fc4f3939bd0061e462659749bba8e4bd3075ba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165299
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-03-26 17:14:40 +01:00
Mike Kaganski f0c32a4de8 Replace some matchAsciiL (and wrong lengths) with match
Change-Id: I6d0b5fa249cb466230183e11fc96a89fad69d45d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165310
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-03-26 15:54:26 +01:00
Mike Kaganski fb94c8f64a Relax SolarMutexReleaser precondition to not require SolarMutex lock
As discussed on https://gerrit.libreoffice.org/c/core/+/164843/2#message-8873d3d119de7206b33bc824f5809b8b1d3d97da,
it is impossible at times to know in advance, if a specific code, that
must not be guarded by SolarMutex (e.g., calling to other threads, which
might need to grab the mutex), will itself be guarded by SolarMutex.
Before this change, a required pre-requisite for SolarMutexReleaser use
was existing lock of SolarMutex; otherwise, an attempt to release it
would call abort(). Thus, in some places we had to grab the mutex prior
to releasing it, and that itself introduced more potential for deadlock.

Now the SolarMutexReleaser is safe to use without the lock, in which
case, it will do nothing.

Change-Id: I8759c2f6ed448598b3be4d6c5109804b5e7523ed
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165262
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-03-25 06:27:32 +01:00
Mike Kaganski ec0e9bee23 Pass m_pOleComponent to lambda by copy
Both m_pOleComponent and the copy are rtl::Reference, so the copy
will ensure the lifetime of the object.
See https://gerrit.libreoffice.org/c/core/+/164986/2#message-5dd187741df3242f47d1037a1f9c9b0fd9bb1f8e

Change-Id: I092281ce41786682b269ba048f102877117391f7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165013
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-03-20 04:41:36 +01:00
Mike Kaganski 0c9f650136 Release the mutex when calling the OLE method
... which may need to be executed on a different thread.

Change-Id: Id9e4b86fd3eafa49139b21e3817aa1ee8aff3dba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164986
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-03-19 06:20:41 +01:00
Mike Kaganski 3e0a2239e9 Introduce a guard to delay processing of idles
In a following scenario, there could be a crash:

1. Platform: a Windows system with MS Word installed.
2. LibreOffice is run in a listener mode;
3. A Java program opens a Writer document in a visible mode, with an
   embedded Word OLE object;
4. It adds some text; then resizes the OLE object; then removes the
   OLE object.

Word OLE objects have OLEMISC_RECOMPOSEONRESIZE flag [1]; this means,
that every re-layout of the document with this object must ask the
OLE server to re-layout the object content. So, the request thread
changes the document text, which triggers idle re-layout or redraw;
the idles start executing immediately in the idle main thread, with
solar mutex locked; then the request thread starts the OLE object
removal operation. The ongoing relayout in main thread would at some
stage need to execute a call to the OLE object, which temporarily
releases the solar mutex (this makes impossible using solar mutex to
synchronize the order of operations in this scenario). Other mutexes
guarding OLE object (in OleEmbeddedObject, and in OleComponent) are
also released for the duration of the call. Thus, the removal that
happens in the request thread proceeds, and the node containing the
OLE object is destroyed, while the main thread (processing exactly
this node) is waiting for the OLE server response, then for mutexes,
to proceed. After that, the main thread would attempt to access the
destroyed node object.

This change introduces a scheduler guard (a RAII object), that sets
a flag to not process idle events during the lifetime of the guard.
In its constructor, it also makes sure, that current pending idle
events are finished. This would make sure that guarded code started
from other threads would not race with idles potentially accessing
the model that is currently in transient state.

[1] https://learn.microsoft.com/en-us/windows/win32/api/oleidl/ne-oleidl-olemisc

Change-Id: I2ef0601ccd8b5872588a88493d1f43e39022dbed
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164753
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-03-13 13:47:53 +01:00
Andrea Gelmini 8b83bd661b Fix typo
Change-Id: I26617232049c6218b99d00e1f69adad42e8249ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164668
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
2024-03-11 19:33:19 +01:00
Andrea Gelmini 83c2a63223 Fix typo
Change-Id: I9d09cb02d5fed17d48f0bc42ac41cf8bad3b66b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164667
Tested-by: Julien Nabet <serval2412@yahoo.fr>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2024-03-11 18:57:32 +01:00
Andrea Gelmini ea1d09b039 Fix typo
Change-Id: Idc184c5155fa69888561fed5709da36c330d1c2e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164666
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2024-03-11 18:56:34 +01:00
Mike Kaganski a00f608e6a Drop old "SvGlobalName order" compatibility hack
It was added in commit 7afe74c37e
(INTEGRATION: CWS os54 (1.21.10); FILE MERGED, 2005-03-11) for
issue #i30510# related to "StampIt". Hopefully now, after almost
20 years, the hack is not needed anymore.

Change-Id: Id39765b9d2c51fd487c48ce06382c068bab08959
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164459
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-03-11 04:45:23 +01:00