Bug 137356 - Files can be opened twice when opened quickly
Summary: Files can be opened twice when opened quickly
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
5.3.0.3 release
Hardware: All Linux (All)
: medium minor
Assignee: Miklos Vajna
URL:
Whiteboard: target:7.1.0
Keywords: bibisected, bisected, regression
: 136190 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-10-09 02:08 UTC by Aron Budea
Modified: 2021-04-23 05:50 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aron Budea 2020-10-09 02:08:51 UTC
Normally, this can be reproduced by quickly double-clicking twice on a document. It will open in two separate windows (two separate editing instances, file editable in both), while it should only be opened once.

Another reproducer: ./soffice file.odt & ./soffice file.odt

For comparison: ./soffice file.odt & (sleep 1; ./soffice file.odt)
This will open the document only once, as expected.

This is a regression from the following commit, ported from AOO, related to bug 38915. Before that, only one window was opened in both scenarios.

https://cgit.freedesktop.org/libreoffice/core/commit/?id=74ac65c49cc1d53b1aa93c2b7c720255867aace2
author		Andrea Pescetti <pescetti@apache.org>	2016-09-06 19:13:44 +0000
committer	Stephan Bergmann <sbergman@redhat.com>	2016-09-21 10:11:29 +0200

#i114963# Enable IPC before OpenClients to allow client connections when printing.
Comment 1 Mike Kaganski 2020-10-09 07:04:03 UTC
But this would still create a single soffice.bin process in the end, right?

So the problem seems to be that we don't detect that two simultaneous attempts to open the same document in the same process are being processed?
Comment 2 Mike Kaganski 2020-10-09 07:26:43 UTC
I could kind of reproduce it on Windows: running this command in cygwin, LibreOffice also tries to open the file twice. The second attempt warns about the file being locked by myself (so the lockfile was already created).

Of course it would be impossible to have two independent editing "sessions" of the same document on Windows own filesystems, even if lock files are disabled, because of filesystem-level locking; but if the filesystem locking would not work (say, using some network shares without own locking), that would be possible also on Windows.
Comment 3 Mike Kaganski 2020-10-09 14:47:41 UTC
The problem seems to be because the second loading event is processed in an Application::Reschedule call in the middle of an active load.

> win32u.dll!NtUserGetMessage()
> user32.dll!GetMessageW()
> vclplug_winlo.dll!ImplSalYield(bool bWait, bool bHandleAllCurrentEvents) Line 490
> 	at C:\lo\src\core\vcl\win\app\salinst.cxx(490)
> vclplug_winlo.dll!WinSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents) Line 528
> 	at C:\lo\src\core\vcl\win\app\salinst.cxx(528)
> vcllo.dll!ImplYield(bool i_bWait, bool i_bAllEvents) Line 446
> 	at C:\lo\src\core\vcl\source\app\svapp.cxx(446)
> vcllo.dll!Application::Yield() Line 511
> 	at C:\lo\src\core\vcl\source\app\svapp.cxx(511)
> vcllo.dll!Dialog::Execute() Line 1030
> 	at C:\lo\src\core\vcl\source\window\dialog.cxx(1030)
> vcllo.dll!SalInstanceDialog::run() Line 1544
> 	at C:\lo\src\core\vcl\source\app\salvtables.cxx(1544)
> uuilo.dll!OpenLockedQueryBox::run() Line 30
> 	at C:\lo\src\core\uui\source\openlocked.hxx(30)
> uuilo.dll!`anonymous namespace'::handleLockedDocumentRequest_(weld::Window * pParent, const rtl::OUString & aDocumentURL, const rtl::OUString & aInfo, const com::sun::star::uno::Sequence<com::sun::star::uno::Reference<com::sun::star::task::XInteractionContinuation>> & rContinuations, unsigned short nMode) Line 98
> 	at C:\lo\src\core\uui\source\iahndl-locking.cxx(98)
> uuilo.dll!UUIInteractionHelper::handleLockedDocumentRequest(const com::sun::star::uno::Reference<com::sun::star::task::XInteractionRequest> & rRequest) Line 215
> 	at C:\lo\src\core\uui\source\iahndl-locking.cxx(215)
> uuilo.dll!UUIInteractionHelper::handleRequest_impl(const com::sun::star::uno::Reference<com::sun::star::task::XInteractionRequest> & rRequest, bool bObtainErrorStringOnly, bool & bHasErrorString, rtl::OUString & rErrorString) Line 809
> 	at C:\lo\src\core\uui\source\iahndl.cxx(809)
> uuilo.dll!UUIInteractionHelper::handleRequest(const com::sun::star::uno::Reference<com::sun::star::task::XInteractionRequest> & rRequest) Line 179
> 	at C:\lo\src\core\uui\source\iahndl.cxx(179)
> uuilo.dll!`anonymous namespace'::UUIInteractionHandler::handle(const com::sun::star::uno::Reference<com::sun::star::task::XInteractionRequest> & rRequest) Line 196
> 	at C:\lo\src\core\uui\source\interactionhandler.cxx(196)
> sfxlo.dll!SfxMedium::ShowLockedDocumentDialog(const o3tl::enumarray<enum LockFileComponent,rtl::OUString> & aData, bool bIsLoading, bool bOwnLock, bool bHandleSysLocked) Line 996
> 	at C:\lo\src\core\sfx2\source\doc\docfile.cxx(996)
> sfxlo.dll!SfxMedium::LockOrigFileOnDemand(bool bLoading, bool bNoUI, bool bTryIgnoreLockFile, o3tl::enumarray<enum LockFileComponent,rtl::OUString> * pLockData) Line 1451
> 	at C:\lo\src\core\sfx2\source\doc\docfile.cxx(1451)
> sfxlo.dll!SfxObjectShell::DoLoad(SfxMedium * pMed) Line 637
> 	at C:\lo\src\core\sfx2\source\doc\objstor.cxx(637)
> sfxlo.dll!SfxBaseModel::load(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & seqArguments) Line 1883
> 	at C:\lo\src\core\sfx2\source\doc\sfxbasemodel.cxx(1883)
> sfxlo.dll!`anonymous namespace'::SfxFrameLoader_Impl::load(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & rArgs, const com::sun::star::uno::Reference<com::sun::star::frame::XFrame> & _rTargetFrame) Line 680
> 	at C:\lo\src\core\sfx2\source\view\frmload.cxx(680)
> fwklo.dll!framework::LoadEnv::impl_loadContent() Line 1157
> 	at C:\lo\src\core\framework\source\loadenv\loadenv.cxx(1157)
> fwklo.dll!framework::LoadEnv::start() Line 395
> 	at C:\lo\src\core\framework\source\loadenv\loadenv.cxx(395)
> fwklo.dll!framework::LoadEnv::startLoading(const rtl::OUString & sURL, const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & lMediaDescriptor, const com::sun::star::uno::Reference<com::sun::star::frame::XFrame> & xBaseFrame, const rtl::OUString & sTarget, long nSearchFlags, LoadEnvFeatures eFeature) Line 300
> 	at C:\lo\src\core\framework\source\loadenv\loadenv.cxx(300)
> fwklo.dll!framework::LoadDispatcher::impl_dispatch(const com::sun::star::util::URL & rURL, const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & lArguments, const com::sun::star::uno::Reference<com::sun::star::frame::XDispatchResultListener> & xListener) Line 107
> 	at C:\lo\src\core\framework\source\dispatch\loaddispatcher.cxx(107)
> fwklo.dll!framework::LoadDispatcher::dispatchWithReturnValue(const com::sun::star::util::URL & rURL, const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & lArguments) Line 59
> 	at C:\lo\src\core\framework\source\dispatch\loaddispatcher.cxx(59)
> comphelper.dll!comphelper::SynchronousDispatch::dispatch(const com::sun::star::uno::Reference<com::sun::star::uno::XInterface> & xStartPoint, const rtl::OUString & sURL, const rtl::OUString & sTarget, const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & lArguments) Line 62
> 	at C:\lo\src\core\comphelper\source\misc\synchronousdispatch.cxx(62)
> sofficeapp.dll!desktop::DispatchWatcher::executeDispatchRequests(const std::vector<desktop::DispatchWatcher::DispatchRequest,std::allocator<desktop::DispatchWatcher::DispatchRequest>> & aDispatchRequestsList, bool bNoTerminate) Line 496
> 	at C:\lo\src\core\desktop\source\app\dispatchwatcher.cxx(496)
> sofficeapp.dll!desktop::RequestHandler::ExecuteCmdLineRequests(desktop::ProcessDocumentsRequest & aRequest, bool noTerminate) Line 1365
> 	at C:\lo\src\core\desktop\source\app\officeipcthread.cxx(1365)
> sofficeapp.dll!desktop::`anonymous namespace'::ProcessEventsClass_Impl::ProcessDocumentsEvent(desktop::`anonymous-namespace'::ProcessEventsClass_Impl * __formal, void * pEvent) Line 289
> 	at C:\lo\src\core\desktop\source\app\officeipcthread.cxx(289)
> sofficeapp.dll!desktop::`anonymous namespace'::ProcessEventsClass_Impl::LinkStubProcessDocumentsEvent(void * instance, void * data) Line 284
> 	at C:\lo\src\core\desktop\source\app\officeipcthread.cxx(284)
> vcllo.dll!Link<void *,void>::Call(void * data) Line 111
> 	at C:\lo\src\core\include\tools\link.hxx(111)
> vcllo.dll!ImplHandleUserEvent(ImplSVEvent * pSVEvent) Line 1993
> 	at C:\lo\src\core\vcl\source\window\winproc.cxx(1993)
> vcllo.dll!ImplWindowFrameProc(vcl::Window * _pWindow, SalEvent nEvent, const void * pEvent) Line 2544
> 	at C:\lo\src\core\vcl\source\window\winproc.cxx(2544)
> vcllo.dll!SalFrame::CallCallback(SalEvent nEvent, const void * pEvent) Line 302
> 	at C:\lo\src\core\vcl\inc\salframe.hxx(302)
> vclplug_winlo.dll!ImplHandleUserEvent(HWND__ * hWnd, __int64 lParam) Line 4144
> 	at C:\lo\src\core\vcl\win\window\salframe.cxx(4144)
> vclplug_winlo.dll!SalFrameWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned __int64 wParam, __int64 lParam, bool & rDef) Line 5793
> 	at C:\lo\src\core\vcl\win\window\salframe.cxx(5793)
> vclplug_winlo.dll!SalFrameWndProcW(HWND__ * hWnd, unsigned int nMsg, unsigned __int64 wParam, __int64 lParam) Line 5900
> 	at C:\lo\src\core\vcl\win\window\salframe.cxx(5900)
> user32.dll!UserCallWinProcCheckWow()
> user32.dll!DispatchMessageWorker()
> vclplug_winlo.dll!ImplSalDispatchMessage(const tagMSG * pMsg) Line 426
> 	at C:\lo\src\core\vcl\win\app\salinst.cxx(426)
> vclplug_winlo.dll!ImplSalYield(bool bWait, bool bHandleAllCurrentEvents) Line 457
> 	at C:\lo\src\core\vcl\win\app\salinst.cxx(457)
> vclplug_winlo.dll!WinSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents) Line 528
> 	at C:\lo\src\core\vcl\win\app\salinst.cxx(528)
> vcllo.dll!ImplYield(bool i_bWait, bool i_bAllEvents) Line 446
> 	at C:\lo\src\core\vcl\source\app\svapp.cxx(446)
> vcllo.dll!Application::Reschedule(bool i_bAllEvents) Line 460
> 	at C:\lo\src\core\vcl\source\app\svapp.cxx(460)
> fwklo.dll!framework::StatusIndicatorFactory::impl_reschedule(bool bForce) Line 521
> 	at C:\lo\src\core\framework\source\helper\statusindicatorfactory.cxx(521)
> fwklo.dll!framework::StatusIndicatorFactory::start(const com::sun::star::uno::Reference<com::sun::star::task::XStatusIndicator> & xChild, const rtl::OUString & sText, long nRange) Line 139
> 	at C:\lo\src\core\framework\source\helper\statusindicatorfactory.cxx(139)
> fwklo.dll!framework::StatusIndicator::start(const rtl::OUString & sText, long nRange) Line 51
> 	at C:\lo\src\core\framework\source\helper\statusindicator.cxx(51)
> swlo.dll!XMLReader::Read(SwDoc & rDoc, const rtl::OUString & rBaseURL, SwPaM & rPaM, const rtl::OUString & rName) Line 630
> 	at C:\lo\src\core\sw\source\filter\xml\swxml.cxx(630)
> swlo.dll!SwReader::Read(const Reader & rOptions) Line 191
> 	at C:\lo\src\core\sw\source\filter\basflt\shellio.cxx(191)
> swlo.dll!SwDocShell::Load(SfxMedium & rMedium) Line 528
> 	at C:\lo\src\core\sw\source\uibase\app\docshini.cxx(528)
> sfxlo.dll!SfxObjectShell::LoadOwnFormat(SfxMedium & rMedium) Line 3101
> 	at C:\lo\src\core\sfx2\source\doc\objstor.cxx(3101)
> sfxlo.dll!SfxObjectShell::DoLoad(SfxMedium * pMed) Line 681
> 	at C:\lo\src\core\sfx2\source\doc\objstor.cxx(681)
> sfxlo.dll!SfxBaseModel::load(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & seqArguments) Line 1883
> 	at C:\lo\src\core\sfx2\source\doc\sfxbasemodel.cxx(1883)
> sfxlo.dll!`anonymous namespace'::SfxFrameLoader_Impl::load(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & rArgs, const com::sun::star::uno::Reference<com::sun::star::frame::XFrame> & _rTargetFrame) Line 680
> 	at C:\lo\src\core\sfx2\source\view\frmload.cxx(680)
> fwklo.dll!framework::LoadEnv::impl_loadContent() Line 1157
> 	at C:\lo\src\core\framework\source\loadenv\loadenv.cxx(1157)
> fwklo.dll!framework::LoadEnv::start() Line 395
> 	at C:\lo\src\core\framework\source\loadenv\loadenv.cxx(395)
> fwklo.dll!framework::LoadEnv::startLoading(const rtl::OUString & sURL, const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & lMediaDescriptor, const com::sun::star::uno::Reference<com::sun::star::frame::XFrame> & xBaseFrame, const rtl::OUString & sTarget, long nSearchFlags, LoadEnvFeatures eFeature) Line 300
> 	at C:\lo\src\core\framework\source\loadenv\loadenv.cxx(300)
> fwklo.dll!framework::LoadDispatcher::impl_dispatch(const com::sun::star::util::URL & rURL, const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & lArguments, const com::sun::star::uno::Reference<com::sun::star::frame::XDispatchResultListener> & xListener) Line 107
> 	at C:\lo\src\core\framework\source\dispatch\loaddispatcher.cxx(107)
> fwklo.dll!framework::LoadDispatcher::dispatchWithReturnValue(const com::sun::star::util::URL & rURL, const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & lArguments) Line 59
> 	at C:\lo\src\core\framework\source\dispatch\loaddispatcher.cxx(59)
> comphelper.dll!comphelper::SynchronousDispatch::dispatch(const com::sun::star::uno::Reference<com::sun::star::uno::XInterface> & xStartPoint, const rtl::OUString & sURL, const rtl::OUString & sTarget, const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> & lArguments) Line 62
> 	at C:\lo\src\core\comphelper\source\misc\synchronousdispatch.cxx(62)
> sofficeapp.dll!desktop::DispatchWatcher::executeDispatchRequests(const std::vector<desktop::DispatchWatcher::DispatchRequest,std::allocator<desktop::DispatchWatcher::DispatchRequest>> & aDispatchRequestsList, bool bNoTerminate) Line 496
> 	at C:\lo\src\core\desktop\source\app\dispatchwatcher.cxx(496)
> sofficeapp.dll!desktop::RequestHandler::ExecuteCmdLineRequests(desktop::ProcessDocumentsRequest & aRequest, bool noTerminate) Line 1365
> 	at C:\lo\src\core\desktop\source\app\officeipcthread.cxx(1365)
> sofficeapp.dll!desktop::Desktop::OpenClients() Line 2098
> 	at C:\lo\src\core\desktop\source\app\app.cxx(2098)
> sofficeapp.dll!desktop::Desktop::OpenClients_Impl(void * __formal) Line 1892
> 	at C:\lo\src\core\desktop\source\app\app.cxx(1892)
> sofficeapp.dll!desktop::Desktop::LinkStubOpenClients_Impl(void * instance, void * data) Line 1874
> 	at C:\lo\src\core\desktop\source\app\app.cxx(1874)
> vcllo.dll!Link<void *,void>::Call(void * data) Line 111
> 	at C:\lo\src\core\include\tools\link.hxx(111)
> vcllo.dll!ImplHandleUserEvent(ImplSVEvent * pSVEvent) Line 1993
> 	at C:\lo\src\core\vcl\source\window\winproc.cxx(1993)
> vcllo.dll!ImplWindowFrameProc(vcl::Window * _pWindow, SalEvent nEvent, const void * pEvent) Line 2544
> 	at C:\lo\src\core\vcl\source\window\winproc.cxx(2544)
> vcllo.dll!SalFrame::CallCallback(SalEvent nEvent, const void * pEvent) Line 302
> 	at C:\lo\src\core\vcl\inc\salframe.hxx(302)
> vclplug_winlo.dll!ImplHandleUserEvent(HWND__ * hWnd, __int64 lParam) Line 4144
> 	at C:\lo\src\core\vcl\win\window\salframe.cxx(4144)
> vclplug_winlo.dll!SalFrameWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned __int64 wParam, __int64 lParam, bool & rDef) Line 5793
> 	at C:\lo\src\core\vcl\win\window\salframe.cxx(5793)
> vclplug_winlo.dll!SalFrameWndProcW(HWND__ * hWnd, unsigned int nMsg, unsigned __int64 wParam, __int64 lParam) Line 5900
> 	at C:\lo\src\core\vcl\win\window\salframe.cxx(5900)
> user32.dll!UserCallWinProcCheckWow()
> user32.dll!DispatchMessageWorker()
> vclplug_winlo.dll!ImplSalDispatchMessage(const tagMSG * pMsg) Line 426
> 	at C:\lo\src\core\vcl\win\app\salinst.cxx(426)
> vclplug_winlo.dll!ImplSalYield(bool bWait, bool bHandleAllCurrentEvents) Line 457
> 	at C:\lo\src\core\vcl\win\app\salinst.cxx(457)
> vclplug_winlo.dll!WinSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents) Line 528
> 	at C:\lo\src\core\vcl\win\app\salinst.cxx(528)
> vcllo.dll!ImplYield(bool i_bWait, bool i_bAllEvents) Line 446
> 	at C:\lo\src\core\vcl\source\app\svapp.cxx(446)
> vcllo.dll!Application::Yield() Line 511
> 	at C:\lo\src\core\vcl\source\app\svapp.cxx(511)
> vcllo.dll!Application::Execute() Line 425
> 	at C:\lo\src\core\vcl\source\app\svapp.cxx(425)
> sofficeapp.dll!desktop::Desktop::Main() Line 1590
> 	at C:\lo\src\core\desktop\source\app\app.cxx(1590)
> vcllo.dll!ImplSVMain() Line 196
> 	at C:\lo\src\core\vcl\source\app\svmain.cxx(196)
> vcllo.dll!SVMain() Line 229
> 	at C:\lo\src\core\vcl\source\app\svmain.cxx(229)
> sofficeapp.dll!soffice_main() Line 98
> 	at C:\lo\src\core\desktop\source\app\sofficemain.cxx(98)
> soffice.bin!sal_main() Line 48
> 	at C:\lo\src\core\desktop\source\app\main.c(48)
> soffice.bin!main(int argc, char * * argv) Line 47
> 	at C:\lo\src\core\desktop\source\app\main.c(47)
> soffice.bin!invoke_main() Line 79
> 	at D:\agent\_work\9\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(79)
> soffice.bin!__scrt_common_main_seh() Line 288
> 	at D:\agent\_work\9\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(288)
> soffice.bin!__scrt_common_main() Line 331
> 	at D:\agent\_work\9\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(331)
> soffice.bin!mainCRTStartup() Line 17
> 	at D:\agent\_work\9\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp(17)
> kernel32.dll!BaseThreadInitThunk()
> ntdll.dll!RtlUserThreadStart()

No idea if the new dispatch can be de delayed if another dispatch in progress is detected?
Comment 4 Miklos Vajna 2020-10-09 21:04:04 UTC
I plan to look at this.
Comment 5 Commit Notification 2020-10-14 16:41:55 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/85467e7cb9920e1131ebb3e30adc290ff36f3fd7

tdf#137356 framework: fix opening the same document twice for long loads

It will be available in 7.1.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Aron Budea 2021-04-23 05:50:52 UTC
*** Bug 136190 has been marked as a duplicate of this bug. ***