Commit graph

1238 commits

Author SHA1 Message Date
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
Xisco Fauli
a38a22c7e5 UnoApiTest: rename load to loadFromURL and use it everywhere
Change-Id: Ie67eebec74f783fa0c29acfb23bb83bc582812b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175724
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2024-10-29 09:11:37 +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
a6a6921123 Use good old string literals in assertXPath and friends
These are only sent to an external API expecting char*-like strings,
or for comparison. Having every assertXPath having three of _[ou]str
is too much syntactic noise, making the unit tests almost unreadable.

Change-Id: Ic004a36ea75e7bfe0b96f405c40f926a957b51cc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174416
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2024-10-05 10:06:44 +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::datatransfer::DataFlavor & aFlavor)
 emboleobj.dll!OleEmbeddedObject::getPreferredVisualRepresentation(__int64 nAspect)
 comphelper.dll!comphelper::EmbeddedObjectContainer::GetGraphicReplacementStream(__int64 nViewAspect, const com::sun::uno::Reference<com::sun::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::uno::Reference<com::sun::util::XModifyListener> & xListener)
 svtlo.dll!svt::`anonymous namespace'::EmbedEventListener_Impl::Create(svt::EmbeddedObjectRef * p)
 svtlo.dll!svt::EmbeddedObjectRef::EmbeddedObjectRef(const com::sun::uno::Reference<com::sun::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::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
Mike Kaganski
e2bfc34d14 Reimplement OleComponentNative_Impl to use IGlobalInterfaceTable
... to make sure that object methods are called in correct apartment

The user-visible problem was, that running a Java code that connects
to LibreOffice, and opening a document with an embedded OLE object
(it was Word object in a specific case, which needs activation at
opening stage, because these objects have OLEMISC_RECOMPOSEONRESIZE
flag), using loadComponentFromURL with "OnMainThread" set to true,
then closing the document, resulted in a hang after several hundreds
iterations. This was caused by Word process, that was started in
background to serve the COM calls, wasn't closed properly, and kept
all the objects in memory, until OOM.

The reason why it wasn't closed was failed call to IOleObject::Close
in OleComponent::CloseObject, which returned RPC_E_WRONG_THREAD,
because the activation of the OLE object happened in the main thread
(because of "OnMainThread"), which is STA, but closing happened in
the handler thread (belonging to MTA).

Similar problems previously were addressed in commits
2dc3a6c273 (framework: allow loading a
component on the main thread, 2018-12-20),
6002014ce0 (framework: allow loading a
component on the main thread, using XDesktop, 2021-04-28),
d5cd62164d (embeddedobj: handle getting
the visible area on a thread, 2021-05-07).
These changes tried different workarounds for the same problem, when
a COM object instantiated in one apartment is later manipulated from
another, which fails. First two handled the case when the document
is loaded from a non-UI thread, and then manipulated with the UI; to
handle that, they introduced flags that delegated opening the file
to the main (UI) thread. The last change tried to handle the reverse
problem of the OLE object instantiated in the main thread was saved
in a handler thread, which again failed; the workaround was, again,
to try to delegate the second attempt to the main thread.

But basically all methods can fail in such circumstations, as shown
in this problem's case. The "OnMainThread" flag must be passed to
fileopen functions explicitly. Also, the workarounds only work by
passing everything to STA, and don't target a case when the calls
must be passed from STA to MTA.

Since Windows 2000, there is IGlobalInterfaceTable, which goal is
to solve this problem. It allows to use an intermediate object,
which can transparently delegate all calls to the correct thread.

This change re-implements how OLE objects are referenced from
OleComponentNative_Impl, using the said IGlobalInterfaceTable.
This should hopefully obsolete the previous workarounds, which
nevertheless are kept for now.

Change-Id: Ia1c590e547ed24a2c7389283aed6cc3d8ea024b0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164457
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-03-11 04:39:58 +01:00
varshneydevansh
cc695e180b tdf#42982: Improve UNO API error reporting
Change-Id: I2eead2d6907cf49d9a8525065d33c3ef43207660
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161779
Tested-by: Jenkins
Reviewed-by: Hossein <hossein@libreoffice.org>
2024-03-10 23:40:21 +01:00
Sarper Akdemir
cb685f603e tdf#158375: make it possible to hot disable embedded objects
Do not require a reload of the current document for the
embedded objects to be disabled.

Also make sure the existing active embedded objects are
disabled when DisableActiveContent is enabled via options
dialog.

Change-Id: I5a8f302af0cac64575c3e5ec6dbe71ec50a15442
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164367
Tested-by: Jenkins
Reviewed-by: Sarper Akdemir <sarper.akdemir.extern@allotropia.de>
2024-03-07 12:30:15 +01:00
Mike Kaganski
957552bee4 Drop some reinterpret_casts
Change-Id: I5bcfe37adbf1f142950a1a2679f22333c711735e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164456
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-03-06 15:21:31 +01:00
Mike Kaganski
fcfffd2d93 Check the correct member
It's m_pViewObject2 that will be dereferenced below.

Change-Id: Ic3696953f013099ee2595a08428ba793c81b6b9c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164455
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-03-06 15:21:24 +01:00
Mike Kaganski
70874f70e4 Simplify a bit
Change-Id: Id9895a3b6e8c09df12c9f9c3c83e1432aa5fff71
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164203
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-03-02 11:17:57 +01:00
Mike Kaganski
74185b8edf Link to oledlg, and use OleUIInsertObjectW directly
... instead of manually loading and using OleUIInsertObjectA.

Change-Id: I597dd44e13edf8c94d83f434b57142c88e5aca6f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163922
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2024-02-26 04:18:07 +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
Caolán McNamara
f0a8b5b81d move IsFuzzing to comphelper
and try something a bit more generic

Change-Id: I1d8256576cd02f0a589df350ba7b53059dd586a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161250
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-12-30 12:45:45 +01:00
Noel Grandin
06fe555abb add some more libraries to libmerged
and fix some resulting symbol name clashes

Change-Id: I57b11494742ef74a97e0afb294b4e44813eaa249
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161074
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-12-29 12:51:00 +01:00
Caolán McNamara
33686f67da make use of toplevel docmodel's UserAllowsLinkUpdate property
Change-Id: Ia560c123c2f9dd08acb7eeaafccee332dd16300e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161133
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-12-21 21:14:25 +01:00
Sarper Akdemir
75df80e34e tdf#158375: further disable embedded objects
there was the possibility of constructing an OOoEmbeddedObjectFactory
or OleEmbeddedObjectFactory directly instead of
UNOEmbeddedObjectCreator.

So disable all createInstance calls for them too. Securing there won't
be active embedded objects.

Change-Id: Ib47ad920d4951790c12d1a8587505cab2f1e126d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160921
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2023-12-20 20:15:02 +01:00
Mike Kaganski
c4d420a7fb Only run test dependent on MS Paint OLE class, if Paint is installed
Nowadays, MS Paint is optional component distributed through MS Store
(https://www.microsoft.com/store/productId/9PCFS5B6T72H); it may be
absent on some systems, resulting in tests relying on it failing.

  [build CUT] embeddedobj_msole
  [_RUN_____] testSaveOnThread::TestBody
  warn:embeddedobj.ole:123152:104988:embeddedobj/source/msole/olevisual.cxx:207: Loaded object has no cached size!
  warn:embeddedobj.ole:123152:104988:embeddedobj/source/msole/olevisual.cxx:232: OleEmbeddedObject::getVisualAreaSize: GetExtent() failed: com.sun.star.embed.UnreachableStateException message: "Class not registered
  Bitmap Image at C:/lo/core/embeddedobj/source/msole/olecomponent.cxx:904" context: class OleComponent
  warn:embeddedobj.ole:123152:104988:embeddedobj/source/msole/olecomponent.cxx:1142:  OleComponent::GetCachedExtent: GetExtent() failed
  warn:embeddedobj.ole:123152:104988:embeddedobj/source/msole/olevisual.cxx:257: OleEmbeddedObject::getVisualAreaSize: GetCachedExtent() failed: com.sun.star.lang.IllegalArgumentException message: "at C:/lo/core/embeddedobj/source/msole/olecomponent.cxx:1143" ArgumentPosition: 0
  warn:embeddedobj.ole:123152:104988:embeddedobj/source/msole/olecomponent.cxx:1160:  OleComponent::GetRecommendedExtent: GetExtent() failed
  warn:embeddedobj.ole:123152:104988:embeddedobj/source/msole/olevisual.cxx:271: OleEmbeddedObject::getVisualAreaSize: GetRecommendedExtent() failed: com.sun.star.lang.IllegalArgumentException message: "at C:/lo/core/embeddedobj/source/msole/olecomponent.cxx:1161" ArgumentPosition: 0
  warn:svtools.misc:123152:104988:svtools/source/misc/embedhlp.cxx:554: EmbeddedObjectRef::GetSize: no visual area size
  warn:svtools.misc:123152:104988:svtools/source/misc/embedhlp.cxx:573: EmbeddedObjectRef::GetSize: empty size, defaulting to 5x5cm
  warn:embeddedobj.ole:123152:104988:embeddedobj/source/msole/olevisual.cxx:207: Loaded object has no cached size!
  warn:embeddedobj.ole:123152:104988:embeddedobj/source/msole/olevisual.cxx:232: OleEmbeddedObject::getVisualAreaSize: GetExtent() failed: com.sun.star.embed.UnreachableStateException message: "Class not registered
  Bitmap Image at C:/lo/core/embeddedobj/source/msole/olecomponent.cxx:904" context: class OleComponent
  warn:embeddedobj.ole:123152:104988:embeddedobj/source/msole/olecomponent.cxx:1142:  OleComponent::GetCachedExtent: GetExtent() failed
  warn:embeddedobj.ole:123152:104988:embeddedobj/source/msole/olevisual.cxx:257: OleEmbeddedObject::getVisualAreaSize: GetCachedExtent() failed: com.sun.star.lang.IllegalArgumentException message: "at C:/lo/core/embeddedobj/source/msole/olecomponent.cxx:1143" ArgumentPosition: 0
  warn:embeddedobj.ole:123152:104988:embeddedobj/source/msole/olecomponent.cxx:1160:  OleComponent::GetRecommendedExtent: GetExtent() failed
  warn:embeddedobj.ole:123152:104988:embeddedobj/source/msole/olevisual.cxx:271: OleEmbeddedObject::getVisualAreaSize: GetRecommendedExtent() failed: com.sun.star.lang.IllegalArgumentException message: "at C:/lo/core/embeddedobj/source/msole/olecomponent.cxx:1161" ArgumentPosition: 0
  warn:svtools.misc:123152:104988:svtools/source/misc/embedhlp.cxx:554: EmbeddedObjectRef::GetSize: no visual area size
  warn:svtools.misc:123152:104988:svtools/source/misc/embedhlp.cxx:573: EmbeddedObjectRef::GetSize: empty size, defaulting to 5x5cm
  C:/lo/core/test/source/xmltesttools.cxx:171:testSaveOnThread::TestBody
  equality assertion failed
  - Expected: 0.1665in
  - Actual  : 1.9685in
  - In <>, attribute 'visible-area-width' of '//style:graphic-properties' incorrect value.

Check the class registration, and exit early if needed.

It is unclear if we should do something specific with MS Paint objects
on Windows, when MS Paint is absent, as we do on Linux; this is just
a quick workaround.

Similar checks might be needed in other tests.

Change-Id: I4d99bc3b13d84da53bdb5aa6259083a68ccc8871
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160597
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-12-11 22:10:18 +01:00
Sarper Akdemir
8d3ac3968e tdf#158375: add expert option to disable active content
adds new expert option DisableActiveContent

Right now only disables active embedded content / OLE.

If OLE content is being imported via
UNOEmbeddedObjectCreator::createInstanceInitFromEntry with the
expert option DisableActiveContent set, the imported OLE object is
now forced to be ODummyEmbeddedObject.

ODummyEmbeddedObject doesn't implement any other state then
embed::EmbedStates::LOADED (i.e. doesn't implement RUNNING,
ACTIVE etc.) which makes it possible to prevent the imported OLE
object becoming active.

The functions that now throw lang::NoSuchElementException are
usually called on new creation of embedded content via UI. But
since the call sites expect the possibility of embedded content
failing to initialize, that is handled by showing a popup stating
some form of `unable to insert`.

A follow-up improvement of disabling insertion of OLE content via
dialogs could be implemented.

Change-Id: Ib558a2a129b491798f5036a7bb269116545be75d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160402
Tested-by: Jenkins
Reviewed-by: Sarper Akdemir <sarper.akdemir.extern@allotropia.de>
2023-12-07 13:07:17 +01:00
Stephan Bergmann
93c0780392 Extended loplugin:ostr: Automatic rewrite O[U]StringLiteral: embeddedobj
Change-Id: I2761e0a093aff75c5660b2b78012277c67eb8e17
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158191
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-10-19 20:32:23 +02:00
Caolán McNamara
7273de2730 check earlier on loading ole objects if parent doc is untrusted referer
Change-Id: Ib1169d5c40ca87f789c71b48124754e073895fcd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158054
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-10-17 10:24:59 +02:00
Caolán McNamara
267be127f2 retain Referer information available in OCommonEmbeddedObject ctor
Change-Id: I2cb901e81de3b7db73cd2088348ddad46ae603dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158052
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-10-16 17:52:18 +02:00
Stephan Bergmann
dcea29c283 Make NC_ constexpr-friendly
...by moving the char8_t -> char reinterpret_cast out of any potential constexpr
paths into a new TranslateId::getId.  And demonstrate constexpr'ability by
making the aCategories var in OApplicationIconControl::Fill
(dbaccess/source/ui/app/AppIconControl.cxx) constexpr.  (And there might be more
such cases that could now be made constexpr.)

Change-Id: I0b4e3292faf8f6b901f9b9e934e1aa6bf0f583ff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157862
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-10-12 18:17:49 +02:00
Mike Kaganski
11aa86140e Improve OleRun error reporting
1. Pass its error message up the call stack as the exception's message.
2. In case of REGDB_E_CLASSNOTREG, also obtain the object's class name
   and append it to the message.
3. Show this information in the message displayed for OLE activation
   error.

This introduces a new SetExtendedMessage method in SfxErrorContext to
store extra information for specific errors.

Change-Id: Id3863276266d992ae407fbfa5568acf5c57aa96f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157372
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-09-28 16:02:55 +02:00
Mike Kaganski
3ae9860b9c OUString -> OUStringLiteral
Change-Id: I80b6c736960badf1a6e3af89740a80f46a651f9f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157305
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-09-27 10:29:32 +02:00
Noel Grandin
fa0e4fa015 loplugin:unodispose in editeng..extensions
Change-Id: I6545cf93b0a101d3a3eea0abe9c1732fcf3dc2d0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156850
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-09-13 09:45:44 +02:00
Noel Grandin
b6b26421a1 split Point/Size/Rectangle into AbsoluteScreenPixel* types
to attempt to make it obvious in code what kind of coordinate
system we are dealing with.

The idea is that by doing this, the compile-time type checking
will flush out inconsistencies between different code.

I started with vcl::Window::OutputToAbsoluteScreenPixel
and worked outwards from there.

Change-Id: Ia967d7a0bb38886695f3a761b85c8b9340ddb1c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154676
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-08-02 08:13:15 +02:00
Noel Grandin
05d1790f74 tdf#156463 crash on exit after editing a chart (gtk3)
regression from
    commit 1ed765c818
    tdf#155235 workaround gtk3 accessiblibility crashes on close

Change-Id: I1a43c7df6394426d8ce09ed382dcc6833dbe1c6b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154893
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-07-25 18:26:32 +02:00