Bug 113548 - Crash when running a certain macro from BASIC editor
Summary: Crash when running a certain macro from BASIC editor
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: graphics stack (show other bugs)
Version:
(earliest affected)
5.3.0.3 release
Hardware: All Windows (All)
: medium major
Assignee: Aron Budea
URL:
Whiteboard: target:6.0.0
Keywords: bibisectNotNeeded, regression
Depends on:
Blocks:
 
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)"]


Attachments

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


Steps:
- 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), 5.4.2.2/ Windows 7.
Comment 1 Aron Budea 2017-10-31 09:00:46 UTC
The crash also occurs in 5.3.0.3, but not in 5.2.0.4, 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)
         m_pOutWin->GrabFocus();
 }
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":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=a83a0345e493b928b0b0b93bf106ddb71df69893

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:
http://wiki.documentfoundation.org/Testing_Daily_Builds

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.