Bug 153374 - Hang using Keyboard viewer
Summary: Hang using Keyboard viewer
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Formula Editor (show other bugs)
Version:
(earliest affected)
7.5.0.3 release
Hardware: x86 (IA32) macOS (All)
: medium normal
Assignee: Patrick Luby (volunteer)
URL:
Whiteboard: target:7.6.0 target:7.5.3
Keywords: bibisected, bisected, regression
Depends on:
Blocks: Performance
  Show dependency treegraph
 
Reported: 2023-02-04 12:31 UTC by bz137195
Modified: 2023-05-17 20:07 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Sample when Recover Document dialog is displayed (122.57 KB, text/plain)
2023-04-12 20:28 UTC, Patrick Luby (volunteer)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bz137195 2023-02-04 12:31:57 UTC
I have had the same bug for about a year. It is on libre, neo and open offices.
Keyboard viewer causes libreoffice to hang and crash. I thought you had (amost) fixed it in the previous version (maybe 7.4.4.7) where it just was a bit wonky at exit. But I’ve just installed  7.5.0 and it is as bad as ever.
Comment 1 bz137195 2023-02-20 03:34:22 UTC
After my original report I installed -
Version: 7.4.5.1 / LibreOffice Community
Build ID: 9c0871452b3918c1019dde9bfac75448afc4b57f
CPU threads: 4; OS: Mac OS X 12.6.3; UI render: default; VCL: osx
Locale: en-GB (en_GB.UTF-8); UI: en-US
Calc: default

it doesn’t hang or crash. But sometimes on exit the LibreOffice 7.4 Document Recovery dialogue is presented without any files listed.

If Keyboard Viewer is closed  Calc operates normally.

Let me know if you need  any experiments run.
Comment 2 Buovjaga 2023-03-27 11:05:09 UTC
If the problem got worse in 7.5, you might clone the 7.5 binary bisecting repository and investigate:
https://wiki.documentfoundation.org/QA/Bibisect/macOS
https://wiki.documentfoundation.org/QA/Bibisect
Comment 3 Mike Little 2023-03-28 07:05:25 UTC
(In reply to bz137195 from comment #0)
> I have had the same bug for about a year. It is on libre, neo and open
> offices.
> Keyboard viewer causes libreoffice to hang and crash. I thought you had
> (amost) fixed it in the previous version (maybe 7.4.4.7) where it just was a
> bit wonky at exit. But I’ve just installed  7.5.0 and it is as bad as ever.

Hello,
Can you provide a link to the original bug report?
Comment 4 Buovjaga 2023-03-28 07:52:53 UTC
(In reply to Mike Little from comment #3)
> (In reply to bz137195 from comment #0)
> > I have had the same bug for about a year. It is on libre, neo and open
> > offices.
> > Keyboard viewer causes libreoffice to hang and crash. I thought you had
> > (amost) fixed it in the previous version (maybe 7.4.4.7) where it just was a
> > bit wonky at exit. But I’ve just installed  7.5.0 and it is as bad as ever.
> 
> Hello,
> Can you provide a link to the original bug report?

This is the original bug report.
Comment 5 bz137195 2023-04-07 22:28:38 UTC
I bisected https://bibisect.libreoffice.org/mac64-7.1.git
 76c416a97157d788f3048dd504fcf5b97be8c027 is the first bad commit
commit 76c416a97157d788f3048dd504fcf5b97be8c027
Author: libreoffice <libreoffice@libreoffices-Mac-mini.local>
Date:   Tue Dec 1 17:39:28 2020 +0100

    source 12e30b658d0adfd00c463be8a7f0d6cf91ee0974
    
    source 12e30b658d0adfd00c463be8a7f0d6cf91ee0974

 LibreOffice.app/Contents/Frameworks/libsmlo.dylib | Bin 1489384 -> 1489336 bytes
 LibreOffice.app/Contents/Resources/setuprc        |   2 +-
 LibreOffice.app/Contents/Resources/versionrc      |   2 +-
 3 files changed, 2 insertions(+), 2 deletions(-)

7.2 and 7.3 also faulty
Comment 6 Buovjaga 2023-04-08 06:57:56 UTC
(In reply to bz137195 from comment #5)
> I bisected https://bibisect.libreoffice.org/mac64-7.1.git
>  76c416a97157d788f3048dd504fcf5b97be8c027 is the first bad commit
> commit 76c416a97157d788f3048dd504fcf5b97be8c027
> Author: libreoffice <libreoffice@libreoffices-Mac-mini.local>
> Date:   Tue Dec 1 17:39:28 2020 +0100
> 
>     source 12e30b658d0adfd00c463be8a7f0d6cf91ee0974
>     
>     source 12e30b658d0adfd00c463be8a7f0d6cf91ee0974
> 
>  LibreOffice.app/Contents/Frameworks/libsmlo.dylib | Bin 1489384 -> 1489336
> bytes
>  LibreOffice.app/Contents/Resources/setuprc        |   2 +-
>  LibreOffice.app/Contents/Resources/versionrc      |   2 +-
>  3 files changed, 2 insertions(+), 2 deletions(-)
> 
> 7.2 and 7.3 also faulty

That commit only touches the Math application.

Can you confirm it by doing in the 7.1 repository

git checkout 76c416a97157d788f3048dd504fcf5b97be8c027

and testing if you get the hang.

Then,

git checkout HEAD~1

and testing if you get the hang.

If you get the hang even after the second checkout, the bibisect result is not correct.
Comment 7 bz137195 2023-04-09 01:23:27 UTC
tested.
hang at 76c416a97
no fault found at 7cda3bb08
Comment 8 Buovjaga 2023-04-12 12:50:06 UTC
Patrick: after a brief discussion in the dev chat, I'm Ccing you in case you are interested. It might be that the bibisect result is relevant after all.
Comment 9 Patrick Luby (volunteer) 2023-04-12 20:28:26 UTC
Created attachment 186629 [details]
Sample when Recover Document dialog is displayed
Comment 10 Patrick Luby (volunteer) 2023-04-12 20:30:55 UTC
I can reproduce this in both LibreOffice 7.5.2.2 and the nightly build. Here are the steps that I did to reproduce the bug:

1. Open a new math formula document
2. Display the macOS Keyboard Viewer
3. Pu the cursor in the input area in the bottom half of the document
4. Input ASCII characters in Keyboard Viewer
5. Save the document using Command-S keys
6. Quit using Command-Q keys

Sometimes it'll work, but sometimes the Recover Document dialog will appear during quitting. I took a sample in the Activity Monitor application when that dialog is display and no buttons are pressed in attachment 186629 [details].

In the sample, it looks like there is a crash in LibreOffice's accessibility code. Specifically, some memory is being deleted twice.
Comment 11 Buovjaga 2023-04-12 21:25:54 UTC
Thanks a lot. As the steps did not mention using Math, I thought the bibisect result was bogus.
Comment 12 Patrick Luby (volunteer) 2023-04-12 21:55:34 UTC
(In reply to Buovjaga from comment #11)
> Thanks a lot. As the steps did not mention using Math, I thought the
> bibisect result was bogus.

Maybe it is indirectly related, who knows? What I found was that when doing the steps in comment 10 was the only time that the catch block code was invoked in the accessibility code. The catch block is where I saw a release call on an autoreleased NSArray (the attributeNames variable was created with [NSMutableArray arrayWithObjects:], not [[NSMutableArray alloc] init:]):

https://gerrit.libreoffice.org/c/core/+/150307/1/vcl/osx/a11ywrapper.mm

Anyway, I'll commit the above patch if it passes gerrit's tests. I am not sure that the patch will fix this bug (I cannot reproduce the bug in my development build). So, if the bug still occurs in the next nightly build, can you take a sample in the Activity Monitor application when the Recover Document dialog appears?
Comment 13 Commit Notification 2023-04-13 00:10:14 UTC
Patrick Luby committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/127eacf630e1712fd5addcabed404b2d33752311

Related: tdf#153374 Don't release autoreleased attributeNames

It will be available in 7.6.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 15 BogdanB 2023-04-13 05:42:21 UTC
Patrick, you can mark this bug as Assigned, Resolved, so on... As you consider the actual status of this bug.
Comment 16 Patrick Luby (volunteer) 2023-04-13 12:04:18 UTC
Marking as resolved/fixed.
Comment 17 Patrick Luby (volunteer) 2023-04-13 12:06:03 UTC
(In reply to bz137195 from comment #14)
> Tested:
> https://dev-builds.libreoffice.org/daily/master/MacOSX-x86_64@tb94-TDF/2023-
> 04-13_04.17.00/LibreOfficeDev_7.6.0.0.alpha0_MacOS_x86-64_sdk.dmg
> 
> Could not find fault.
> 

Thank you for testing my fix. Marking as verified/fixed.

If you see the crash again, feel free to reopen this bug.
Comment 18 Commit Notification 2023-04-13 16:29:58 UTC
Patrick Luby committed a patch related to this issue.
It has been pushed to "libreoffice-7-5":

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

Related: tdf#153374 Don't release autoreleased attributeNames

It will be available in 7.5.3.

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 19 bz137195 2023-05-17 20:07:30 UTC
I have submitted https://bugs.documentfoundation.org/show_bug.cgi?id=155376
I’ve added this comment in case the new behaviour is related to your fix