Bug 113548 - Crash when running a certain macro from BASIC editor
Summary: Crash when running a certain macro from BASIC editor
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: graphics stack (show other bugs)
(earliest affected) release
Hardware: All Windows (All)
: medium major
Assignee: Aron Budea
Whiteboard: target:6.0.0
Keywords: bibisectNotNeeded, regression
Depends on:
Reported: 2017-10-31 08:57 UTC by Aron Budea
Modified: 2017-10-31 19:26 UTC (History)
1 user (show)

See Also:
Crash report or crash signature: ["vcl::Window::ImplGrabFocus(GetFocusFlags)"]


Note You need to log in before you can comment on or make changes to this bug.
Description Aron Budea 2017-10-31 08:57:14 UTC
Add the following BASIC macro to My Macros:

Sub Goback_to_normal_view
Dim document   as object
Dim dispatcher as object
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
Dim args(0) as new com.sun.star.beans.PropertyValue
dispatcher.executeDispatch(document, ".uno:_SwitchViewShell0", "", 0, args())
End Sub

- Start a new HTML document.
- Save it.
- Switch to View -> HTML Source.
- Go to the macro editor (Tools -> Macros -> Organize Macros -> LibreOffice Basic...; find the macro and click Edit).
- Run macro from the editor.

=> There's a crash.
See report: http://crashreport.libreoffice.org/stats/crash_details/f084c009-4103-4cd8-bec6-884191626551

There's no crash if the macro is run via Tools -> Macros -> Run Macro...
Though sometimes I get "JRE is Defective" error there.

Observed using 6.0 master build (dc55f0618cae0e0ec7877eda065cc4b387e16bfb), Windows 7.
Comment 1 Aron Budea 2017-10-31 09:00:46 UTC
The crash also occurs in, but not in, so it's a regression.
It might be Windows-only.
Comment 2 Aron Budea 2017-10-31 09:30:06 UTC
The trace is somewhat similar to bug 105121's.
Comment 3 Maxim Monastirsky 2017-10-31 09:58:32 UTC
(In reply to Aron Budea from comment #2)
> The trace is somewhat similar to bug 105121's.
Not directly related to bug 105121, but this is a common pattern since the VclPtr conversion to have the GetFocus method of a window called during its dispose, and the GetFocus method tries to set the focus to one of its child controls, which will crash if this particular control was already destructed to this point. There are dozens of similar bugs in Bugzilla. The usual fix we apply in those cases is to add a check inside GetFocus, whether the child is still valid, so you might want to try this (can't do any development myself right now):

 void SwSrcEditWindow::GetFocus()
+    if (m_pOutWin)
Comment 4 Aron Budea 2017-10-31 12:13:39 UTC
That's it, thanks for the hint, Maxim!
Comment 5 Commit Notification 2017-10-31 19:20:54 UTC
Aron Budea committed a patch related to this issue.
It has been pushed to "master":


tdf#113548: another case of crash in GrabFocus during dispose

It will be available in 6.0.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 6 Aron Budea 2017-10-31 19:26:57 UTC
It was Windows-only, too.