Bug 156721 - Crash if cursor in Basic IDE is in a macro from a document and that document is closed
Summary: Crash if cursor in Basic IDE is in a macro from a document and that document ...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: UI (show other bugs)
Version:
(earliest affected)
7.6.0.0 alpha0+
Hardware: All All
: high major
Assignee: Not Assigned
URL:
Whiteboard: target:24.2.0 target:7.6.1
Keywords: bibisected, bisected, regression
Depends on:
Blocks:
 
Reported: 2023-08-10 17:14 UTC by Regina Henschel
Modified: 2023-08-23 07:28 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
presentation containing macros (46.68 KB, application/vnd.oasis.opendocument.presentation)
2023-08-10 17:14 UTC, Regina Henschel
Details
Callstack (7.66 KB, text/plain)
2023-08-18 20:42 UTC, Regina Henschel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Regina Henschel 2023-08-10 17:14:52 UTC
Created attachment 188915 [details]
presentation containing macros

Open attached 'PresentationInclMacro.odp' document and allow macro execution.
Open the Basic IDE. (Tools > Macros > Edit Macros)
Go to the library 'MiniExampleMCGR' in 'PresentationInclMacro.odp' and then to module 'Main'.
Make sure the cursor is in the edit window, e.g at sub  AssignExampleGradientToSelectedShape.

Now you have an open Basic IDE and an open presentation document.

Go back to the document. Close it. => Crash.

Expected: The Basic IDE puts the cursor into an existing library, e.g. 'Standard' from 'My Macros & Dialogs', which always exists, and then silently removes the document from the 'Object Catalog'.
Comment 1 Regina Henschel 2023-08-18 20:42:45 UTC
Created attachment 189034 [details]
Callstack
Comment 2 Kira Tubo 2023-08-19 03:00:48 UTC
Possibly a duplicate of Bug 140339. Will confirm with QA team.
Comment 3 Buovjaga 2023-08-19 07:01:02 UTC
Bibisected with win64-7.6 to f3e127217d8daa443b8eda52ac4810e375cc7d63
use comphelper::WeakComponentImplHelper in DocumentEventNotifier::Impl

Commit touches basctl/source/basicide/doceventnotifier.cxx
Double-checked the previous commit doesn't crash.
Comment 4 Julien Nabet 2023-08-19 14:27:58 UTC
Just for the record, on pc Debian x86-64 with master sources updated today, I got no crash but an hang.
Comment 5 Buovjaga 2023-08-19 14:39:47 UTC
(In reply to Julien Nabet from comment #4)
> Just for the record, on pc Debian x86-64 with master sources updated today,
> I got no crash but an hang.

Yeah, that was my experience on Linux master as well (dbgutil). That's why I thought it better to bisect on Win.
Comment 6 Julien Nabet 2023-08-19 20:27:07 UTC
Ctrl-C the hang, I noticed this:
#7  0x00007f672079f541 in std::unique_lock<std::mutex>::unique_lock(std::mutex&) (this=0x7ffd61b12bf8, __m=...) at /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unique_lock.h:71
#8  0x00007f67208646a2 in basctl::DocumentEventNotifier::Impl::documentEventOccured(com::sun::star::document::DocumentEvent const&) (this=0x557f4d20a8e0, _rEvent=...)
    at basctl/source/basicide/doceventnotifier.cxx:119
#9  0x00007f676dca1041 in (anonymous namespace)::SfxGlobalEvents_Impl::implts_notifyListener(com::sun::star::document::DocumentEvent const&)::$_1::operator()(com::sun::star::uno::Reference<com::sun::star::document::XDocumentEventListener> const&) const (this=0x7ffd61b12d08, xListener=uno::Reference to (basctl::DocumentEventNotifier::Impl *) 0x557f4d20a918) at sfx2/source/notify/globalevents.cxx:493
#10 0x00007f676dca0e81 in comphelper::OInterfaceContainerHelper4<com::sun::star::document::XDocumentEventListener>::forEach<(anonymous namespace)::SfxGlobalEvents_Impl::implts_notifyListener(com::sun::star::document::DocumentEvent const&)::$_1>(std::unique_lock<std::mutex>&, (anonymous namespace)::SfxGlobalEvents_Impl::implts_notifyListener(com::sun::star::document::DocumentEvent const&)::$_1 const&) const
    (this=0x557f4d150df8, rGuard=..., func=...) at include/comphelper/interfacecontainer4.hxx:304
#11 0x00007f676dca0aa0 in (anonymous namespace)::SfxGlobalEvents_Impl::implts_notifyListener(com::sun::star::document::DocumentEvent const&) (this=0x557f4d150d50, aEvent=...)
    at sfx2/source/notify/globalevents.cxx:490
#12 0x00007f676dc9e0f2 in (anonymous namespace)::SfxGlobalEvents_Impl::documentEventOccured(com::sun::star::document::DocumentEvent const&) (this=0x557f4d150d50, Event=...)
    at sfx2/source/notify/globalevents.cxx:226
#13 0x00007f676dc38dac in (anonymous namespace)::NotifySingleListenerIgnoreRE<com::sun::star::document::XDocumentEventListener, com::sun::star::document::DocumentEvent>::operator()(com::sun::star::uno::Reference<com::sun::star::document::XDocumentEventListener> const&) const (this=0x7ffd61b13000, listener=uno::Reference to ((anonymous namespace)::SfxGlobalEvents_Impl *) 0x557f4d150d98)
    at sfx2/source/doc/sfxbasemodel.cxx:3280
#14 0x00007f676dc28999 in comphelper::OInterfaceContainerHelper2::forEach<com::sun::star::document::XDocumentEventListener, (anonymous namespace)::NotifySingleListenerIgnoreRE<com::sun::star::document::XDocumentEventListener, com::sun::star::document::DocumentEvent> >((anonymous namespace)::NotifySingleListenerIgnoreRE<com::sun::star::document::XDocumentEventListener, com::sun::star::document::DocumentEvent> const&)
    (this=0x557f508c4140, func=...) at include/comphelper/interfacecontainer2.hxx:271
#15 0x00007f676dc28056 in SfxBaseModel::postEvent_Impl(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::frame::XController2> const&, com::sun::star::uno::Any const&)
    (this=0x557f5123bfe0, aName="OnTitleChanged", xController=empty uno::Reference, supplement=uno::Any(void)) at sfx2/source/doc/sfxbasemodel.cxx:3314
#16 0x00007f676dc275d8 in SfxBaseModel::Notify(SfxBroadcaster&, SfxHint const&) (this=0x557f5123bfe0, rBC=..., rHint=...) at sfx2/source/doc/sfxbasemodel.cxx:2951
#17 0x00007f676cd587a4 in SfxBroadcaster::Broadcast(SfxHint const&) (this=0x557f53cdd210, rHint=...) at svl/source/notify/SfxBroadcaster.cxx:40
#18 0x00007f676db771e7 in SfxObjectShell::SetTitle(rtl::OUString const&) (this=0x557f53cdd210, rTitle="My Macros & Dialogs.Standard") at sfx2/source/doc/objmisc.cxx:704
#19 0x00007f6720805821 in basctl::Shell::SetMDITitle() (this=0x557f5123bbd0) at basctl/source/basicide/basides2.cxx:121
#20 0x00007f672080a37a in basctl::Shell::SetCurLib(basctl::ScriptDocument const&, rtl::OUString const&, bool, bool) (this=0x557f5123bbd0, rDocument=..., aLibName="Standard", bUpdateWindows=true, bCheck=false)
    at basctl/source/basicide/basidesh.cxx:961
#21 0x00007f672080cad5 in basctl::Shell::onDocumentClosed(basctl::ScriptDocument const&) (this=0x557f5123bbd0, _rDocument=...) at basctl/source/basicide/basidesh.cxx:347
#22 0x00007f6720864a64 in basctl::DocumentEventNotifier::Impl::documentEventOccured(com::sun::star::document::DocumentEvent const&) (this=0x557f4d20a8e0, _rEvent=...)
    at basctl/source/basicide/doceventnotifier.cxx:166

So it seems we need a kind of recursive lock/mutex/guard (sorry I don't get the difference between all of these).
Comment 7 Commit Notification 2023-08-21 12:05:26 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/ab38a8d13de0b14b3c389ef27152aac958033401

tdf#156721 Crash if cursor in Basic IDE is in a macro from a document..

It will be available in 24.2.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 8 Julien Nabet 2023-08-21 12:39:36 UTC
Noel: I confirm I don't reproduce the crash anymore after your fix, thank you! :-)
Comment 9 Commit Notification 2023-08-23 07:28:47 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "libreoffice-7-6":

https://git.libreoffice.org/core/commit/883947f5c26f7b672954d0c051b171e70a74734b

tdf#156721 Crash if cursor in Basic IDE is in a macro from a document..

It will be available in 7.6.1.

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.