Bug 158171 - Crash when double-clicking DeepL translation dialog OK button
Summary: Crash when double-clicking DeepL translation dialog OK button
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.5.0.0 alpha0+
Hardware: All Linux (All)
: medium critical
Assignee: Julien Nabet
URL:
Whiteboard: target:24.2.0 target:7.6.4
Keywords: haveBacktrace, implementationError
Depends on:
Blocks: Crash
  Show dependency treegraph
 
Reported: 2023-11-10 17:42 UTC by Stéphane Guillou (stragu)
Modified: 2023-11-13 10:56 UTC (History)
2 users (show)

See Also:
Crash report or crash signature: ["SwTranslateLangSelectDlg::LinkStubLangSelectTranslateHdl(void*, weld::Button&)"]


Attachments
LO 24.2alpha0+ debug build minidump (780.88 KB, application/vnd.tcpdump.pcap)
2023-11-10 17:42 UTC, Stéphane Guillou (stragu)
Details
bt (5.46 KB, text/plain)
2023-11-11 14:51 UTC, Julien Nabet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stéphane Guillou (stragu) 2023-11-10 17:42:11 UTC
Created attachment 190785 [details]
LO 24.2alpha0+ debug build minidump

Steps:
1. Turn on the DeepL translation feature (no need for a valid API URL or key to reproduce!): https://help.libreoffice.org/7.6/en-US/text/shared/optionen/translatetools.html
2. Select a word
3. Tools > Translate...
4. Pick a language
5. Double-click on "OK"

Result: crash (after closing the warnings if you experience bug 152706)
Reproducibility might depend on how quick the operation is.

Version: 7.5.8.2 (X86_64) / LibreOffice Community
Build ID: f718d63693263970429a68f568db6046aaa9df01
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 3aca2d9776a871f15009a1aa70628ba3a03ee147
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

And since the feature was available with e20d2de7836da52dbf9e528d1043b1e188097bfd (tested with linux-64-7.5 bibisect repo).

Reproduced with gen and gtk3 VCL plugins.
Crash report for 7.5: https://crashreport.libreoffice.org/stats/crash_details/675fc47d-53ac-47b2-90a3-86e2353faddf

Current debug build doesn't let me open Writer with --backtrace, so attached is a minidump.
Comment 1 Julien Nabet 2023-11-10 20:01:43 UTC
On pc Debian x86-64 with master sources updated today, I don't reproduce this.

1. Turn on the DeepL translation feature (no need for a valid API URL or key to reproduce!): https://help.libreoffice.org/7.6/en-US/text/shared/optionen/translatetools.html
=> ok since I don't know DeepL servers, I let the boxes (API URL and Authentication key) empty

2. Select a word
=> ok

3. Tools > Translate...
=> The option is grayed, I can't select it.
Comment 2 Stéphane Guillou (stragu) 2023-11-10 22:37:22 UTC
(In reply to Julien Nabet from comment #1)
> => ok since I don't know DeepL servers, I let the boxes (API URL and
> Authentication key) empty
> [...]
> => The option is grayed, I can't select it.
It should become active if you put random characters in the fields
Comment 3 Julien Nabet 2023-11-11 14:51:49 UTC
Created attachment 190790 [details]
bt

Thank you for the feedback, I could reproduce the crash.
Comment 4 Julien Nabet 2023-11-11 14:53:43 UTC
Now ok it's a crash but it's quite unexpected to double click on a "Ok" button.
Comment 5 Julien Nabet 2023-11-11 15:01:36 UTC
I gave a try with https://gerrit.libreoffice.org/c/core/+/159322
Comment 6 Caolán McNamara 2023-11-12 20:50:50 UTC
This totally confused me initially. It is not normal that a double click can cause a problem like this, otherwise we would have thousands of crashes everywhere. But I see why this one is different.

LangSelectTranslateHdl calls
SwTranslateHelper::TranslateDocumentCancellable
and that calls
Application::Yield() in a loop

and that basically means that LibreOffice will look for events and handle them due to that loop so...

When you double click, you get one click that calls LangSelectTranslateHdl, then execution is in TranslateDocumentCancellable and LibreOffice processes outstanding events because of the Yield(). The 2nd click is handled (while we have not yet exited TranslateDocumentCancellable and so not exited the 1st LangSelectTranslateHdl) and LangSelectTranslateHdl gets called again, so we have LangSelectTranslateHdl basically inside LangSelectTranslateHdl.

The inside one then exits and "m_xDialog->response(RET_OK)" is called to destroy the dialog, and so we then return to the outer LangSelectTranslateHdl and it has been already destroyed so we crash.
Comment 7 Commit Notification 2023-11-12 20:58:21 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/79f92d09ec52f0777fc03ff1d057a11b45e73f6d

tdf#158171: fix crash when double-clicking DeepL translation dialog OK button

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 Commit Notification 2023-11-13 00:18:38 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-7-6":

https://git.libreoffice.org/core/commit/45f5fe188769bdc220752841e6588f9c020672f8

tdf#158171: fix crash when double-clicking DeepL translation dialog OK button

It will be available in 7.6.4.

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 9 Stéphane Guillou (stragu) 2023-11-13 10:56:47 UTC
Verified the fix in:

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 79f92d09ec52f0777fc03ff1d057a11b45e73f6d
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Thank you both, Julien and Caolán!