Bug 105409 - Crash when right-click on spelling error or grammar error when contextual menu is modified via API
Summary: Crash when right-click on spelling error or grammar error when contextual men...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.3.0.1 rc
Hardware: All All
: highest critical
Assignee: Maxim Monastirsky
URL:
Whiteboard: target:5.4.0 target:5.3.1
Keywords: regression
: 105915 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-01-18 10:12 UTC by Olivier R.
Modified: 2017-02-15 14:39 UTC (History)
6 users (show)

See Also:
Crash report or crash signature: ["Menu::~Menu()"]


Attachments
Text to test the grammar checker and spellchecker (9.08 KB, application/vnd.oasis.opendocument.text)
2017-01-18 10:16 UTC, Olivier R.
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier R. 2017-01-18 10:12:37 UTC
Description:
LO crashes (on error message, no warning) when right-clicking on a spelling mistake or a grammar mistake, if the contextual menu is modified by an extension. Use of XContextMenuInterceptor.

Steps to Reproduce:
1. Install the extension Grammalecte.
http://www.dicollecte.org/grammalecte/oxt/Grammalecte-fr-v0.5.14.oxt

2. Load the attached file.

3. Right-click on the spelling mistake or on the grammar mistake. Release the menu, or select a suggestion.

Actual Results:  
When clicking on the suggestion of the grammar checker or the spellchecker, LO crashes. It usually crashes also even if you choose to do nothing, when the contextual menu is released.

Expected Results:
No crash.


Reproducible: Always

User Profile Reset: Yes

Additional Info:
Deactivating the interception of the contextual menu solves the issue. But the XContextMenuInterceptor is now useless.


User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:50.0) Gecko/20100101 Firefox/50.0
Comment 1 Olivier R. 2017-01-18 10:16:22 UTC
Created attachment 130518 [details]
Text to test the grammar checker and spellchecker
Comment 2 Olivier R. 2017-01-18 10:17:15 UTC
Tagged as regression as it used to work.
Comment 3 Olivier R. 2017-01-18 10:19:38 UTC
Additional information:

The contextual menu is properly modified as expected via the API. It works as it should until the contextual menu disappears.
Comment 4 Xisco Faulí 2017-01-18 12:31:44 UTC
I can't reproduce it in

Version: 5.4.0.0.alpha0+
Build ID: 4b3e8de6b3cb971b02aa0cb90aceb9e104071d3b
CPU Threads: 4; OS Version: Linux 4.8; UI Render: default; VCL: gtk2; 
Locale: ca-ES (ca_ES.UTF-8); Calc: group
Comment 5 Xisco Faulí 2017-01-18 12:40:16 UTC
it seems to be a problem with the extension:

Traceback (most recent call last):
  File "/home/xisco/libreoffice/instdir/share/uno_packages/cache/uno_packages/lu146482xd88c.tmp_/Grammalecte-fr-v0.5.14.oxt/ContextMenu.py", line 134, in __init__
    oDict = IBDAWG("french.bdic")
  File "/home/xisco/libreoffice/instdir/share/uno_packages/cache/uno_packages/lu146482xd88c.tmp_/Grammalecte-fr-v0.5.14.oxt/pythonpath/grammalecte/ibdawg.py", line 16, in __init__
    self.by = pkgutil.get_data(__package__, "_dictionaries/" + sDicName)
  File "/usr/lib/python3.5/pkgutil.py", line 629, in get_data
    return loader.get_data(resource_name)
  File "<frozen importlib._bootstrap_external>", line 826, in get_data
FileNotFoundError: [Errno 2] No such file or directory: '/home/xisco/libreoffice/instdir/share/uno_packages/cache/uno_packages/lu146482xd88c.tmp_/Grammalecte-fr-v0.5.14.oxt/pythonpath/grammalecte/_dictionaries/french.bdic'

Is there any additional step I have to perform in order to reproduce the crash ?
Comment 6 Olivier R. 2017-01-18 12:49:46 UTC
Sorry, reload the extension and retry, please.
There was another issue (unrelated to this one) with Linux users.
Comment 7 Jacques Guilleron 2017-01-18 13:20:31 UTC
Hi Olivier, Xisco,

I reproduce with: 

LO 5.3.0.1 Build ID: 3b800451b1d0c48045de03b5b3c7bbbac87f20d9
Threads CPU : 2; Version de l'OS :Windows 6.1; UI Render : par défaut; Moteur de mise en page : nouveau; 
Locale : fr-FR (fr_FR); Calc: CL
under Windows 7 Home

Crashes differ on grammar or spelling errors. Crahes reports are available at:
crashreport.libreoffice.org/stats/crash_details/eb3b43e0-a078-494a-b821-f7b9728cfcd6
crashreport.libreoffice.org/stats/crash_details/068501d1-8c32-43ca-bbdc-2200749ad834

Works as expected with the same extension on:
Lo 5.2.4.2 (x64) Build ID: 3d5603e1122f0f102b62521720ab13a38a4e0eb0
Threads CPU : 2; Version de l'OS :Windows 6.1; UI Render : par défaut; 
Locale : fr-FR (fr_FR); Calc: CL
Comment 8 Xisco Faulí 2017-01-18 13:25:03 UTC
Hi Jacques,
Could you please bibisect it in onder to find which commit introduced this regressions? More information: https://wiki.documentfoundation.org/QA/Bibisect/Windows
Comment 9 Jacques Guilleron 2017-01-18 13:31:07 UTC
Hi Xisco,

I wiil try, but till now I found some diffulties to do that.

Jacques
Comment 10 Olivier R. 2017-01-18 13:31:36 UTC
On my PC, the crashreport dialog didn’t appear. Neither on Windows, neither on Linux.
I tried to bibisect on Windows, but the extension doesn’t work at all in this case. No idea why. I’ll try on Linux.
Comment 11 Xisco Faulí 2017-01-18 13:36:59 UTC
(In reply to Olivier R. from comment #10)
> On my PC, the crashreport dialog didn’t appear. Neither on Windows, neither
> on Linux.
> I tried to bibisect on Windows, but the extension doesn’t work at all in
> this case. No idea why. I’ll try on Linux.

That would be great.
On the other hand, you can also try to provide the crash's backtrace. More info: https://wiki.documentfoundation.org/How_to_get_a_backtrace_with_WinDbg
Comment 12 Olivier R. 2017-01-18 17:30:21 UTC
I bibisected on Linux. And I had no crash at all with “master” and “oldest”.
So I tried with the latest master build I found:

Version: 5.4.0.0.alpha0+
Build ID: ac2105e77795970e9131092caae78fd42c86f6d9
CPU Threads: 8; OS Version: Windows 6.1; UI Render: default; 
TinderBox: Win-x86@62-merge-TDF, Branch:MASTER, Time: 2017-01-16_23:47:13
Locale: fr-FR (fr_FR); Calc: CL

This times, LO freezes if I right-click on a grammar error or on a spellchecr error. These times, I have to kill the process manually.
Then when I restart LO, it sends crash report:
http://crashreport.libreoffice.org/stats/crash_details/9edac3f2-a8d5-460c-8002-dabe93d18dc1
http://crashreport.libreoffice.org/stats/crash_details/e6414ea6-d8de-4e51-89b1-70678e93968e

Which both concern mergedlo.dll

I’ll try again with other versions tomorrow.
Comment 13 Olivier R. 2017-01-18 20:08:54 UTC
With the daily build:
Version: 5.3.1.0.0+
Build ID: 832856e058477dd0edabbe1448f41fbc969d4f7e
CPU Threads: 8; OS Version: Windows 6.1; UI Render: default; Layout Engine: new; 
TinderBox: Win-x86@62-merge-TDF, Branch:libreoffice-5-3, Time: 2017-01-18_07:05:46
Locale: fr-FR (fr_FR); Calc: CL

LO also freezes and I have to kill the process manually.
The crash reporter also failed to send reports.
Error message: “Error.”
Comment 14 Commit Notification 2017-01-18 21:45:15 UTC
Maxim Monastirsky committed a patch related to this issue.
It has been pushed to "master":

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

tdf#105409 Use ScopedVclPtr

It will be available in 5.4.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 15 Maxim Monastirsky 2017-01-18 22:07:49 UTC
With that patch it doesn't crash anymore under Linux, but I got different backtrace, so it still needs to be tested with Windows builds.

To reproduce this under Linux you must use SAL_USE_VCLPLUGIN=gen. gtk/gtk3 have different lifecycle for menus, probably because GtkSalMenu holds a hard reference on the parent menu.
Comment 16 Xisco Faulí 2017-01-18 22:17:44 UTC
(In reply to Maxim Monastirsky from comment #15)
> With that patch it doesn't crash anymore under Linux, but I got different
> backtrace, so it still needs to be tested with Windows builds.
> 
> To reproduce this under Linux you must use SAL_USE_VCLPLUGIN=gen. gtk/gtk3
> have different lifecycle for menus, probably because GtkSalMenu holds a hard
> reference on the parent menu.

wow, that was fast. thanks for fixing this.

@Olivier, tomorrow a new build containing the fix will be available at http://dev-builds.libreoffice.org/daily/master/Win-x86@42/. Could you please download it and test it to see if it's fixed on Windows as well?
Comment 17 Olivier R. 2017-01-19 08:41:12 UTC
Tested on:
Version: 5.4.0.0.alpha0+
Build ID: bbf40e3b5d06bd1437b097ed2703179026d1e871
CPU Threads: 8; OS Version: Windows 6.1; UI Render: default; 
TinderBox: Win-x86@42, Branch:master, Time: 2017-01-19_01:45:05
Locale: fr-FR (fr_FR); Calc: CL

It works. Thanks for the fix.
Can it be backported to 5.3 also?
Comment 18 Maxim Monastirsky 2017-01-19 17:52:56 UTC
(In reply to Olivier R. from comment #17)
> It works. Thanks for the fix.
> Can it be backported to 5.3 also?

Hi Olivier,

Thanks for testing. Backport is in gerrit:

https://gerrit.libreoffice.org/33324/
Comment 19 Commit Notification 2017-01-22 20:57:38 UTC
Maxim Monastirsky committed a patch related to this issue.
It has been pushed to "libreoffice-5-3":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=ff0fbfab197f6d717fd7f0afed2954356b3fe791&h=libreoffice-5-3

tdf#105409 Use ScopedVclPtr

It will be available in 5.3.1.

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 20 Pierre C 2017-01-24 09:47:54 UTC
Tested on 
Version: 5.3.1.0.0+
Build ID: c9ab894ae846185a0341656922b0aa1632bfe886
CPU Threads: 4; OS Version: Windows 6.2; UI Render: default; Layout Engine: new; 
TinderBox: Win-x86@62-merge-TDF, Branch:libreoffice-5-3, Time: 2017-01-22_22:43:21
Locale: fr-FR (fr_FR); Calc: group
It works fine
It would be great to have this patch for 5.3.0.3
Comment 21 Caolán McNamara 2017-02-10 12:13:55 UTC
*** Bug 105915 has been marked as a duplicate of this bug. ***