Bug 148683 - Editing: Crash when deleting a piece of text with change tracking enabled, but hidden
Summary: Editing: Crash when deleting a piece of text with change tracking enabled, bu...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.0 all versions
Hardware: All All
: medium normal
Assignee: Miklos Vajna
URL:
Whiteboard: target:7.4.0 target:7.3.4 target:7.2....
Keywords: wantBacktrace
Depends on:
Blocks:
 
Reported: 2022-04-20 10:03 UTC by Padia Rashesh
Modified: 2022-05-17 23:44 UTC (History)
2 users (show)

See Also:
Crash report or crash signature: ["SwFntObj::DrawText(SwDrawTextInfo &)"]


Attachments
document to reproduce the issue (15.05 KB, application/vnd.oasis.opendocument.text)
2022-04-20 10:03 UTC, Padia Rashesh
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Padia Rashesh 2022-04-20 10:03:01 UTC
Created attachment 179679 [details]
document to reproduce the issue

Editing: Crash when deleting a piece of text with change tracking enabled, but hidden

After opening it in Writer, select the following piece of text, and press Delete:
"either contributed [...] or funded"

-> Crash.

In a debug build, it crashes with the following assert:

sw/source/core/inc/drawfont.hxx:122: SwDrawTextInfo::SwDrawTextInfo(const SwViewShell*, OutputDevice&, const SwScriptInfo*, const rtl::OUString&, TextFrameIndex, TextFrameIndex, sal_uInt16, bool, const vcl::text::TextLayoutCache*): Assertion `(nLen == TextFrameIndex(COMPLETE_STRING)) ? (nIdx.get() < rText.getLength()) : (nIdx + nLen).get() <= rText.getLength()' failed.
Comment 1 Xisco Faulí 2022-04-20 13:26:11 UTC
For me, it crashes if I remove 'either contributed by volunteers'
Comment 2 Xisco Faulí 2022-04-20 13:26:59 UTC
Reproduced in

Version: 7.4.0.0.alpha0+ / LibreOffice Community
Build ID: 8e4453c2117b6c3bb15be6b949a0a8a43df66647
CPU threads: 8; OS: Linux 5.10; UI render: default; VCL: gtk3
Locale: es-ES (es_ES.UTF-8); UI: en-US
Calc: threaded
Comment 3 Xisco Faulí 2022-04-20 13:32:47 UTC
Also reproduced in

Version: 6.4.0.0.alpha1+
Build ID: 9bc848cf0d301aa57eabcffa101a1cf87bad6470
CPU threads: 8; OS: Linux 5.10; UI render: default; VCL: gtk3; 
Locale: es-ES (es_ES.UTF-8); UI-Language: en-US
Calc: threaded
Comment 4 Telesto 2022-04-20 15:43:53 UTC
To check after the fix is in: 
1.  Select the following piece of text, and press Delete:
"either contributed [...] or funded"
2. Press CTRL+Z

It currently doesn't restore properly (on non-debug build); comment is lost. But maybe it's related to the assert.
Comment 5 Michael Stahl (allotropia) 2022-04-22 19:45:55 UTC
sorry, i was too busy to answer properly on IRC.

some more tips for debugging:

* the text frame is formatted in SwTextFrame::Format - set a break there and check that when it is called following the delete, the GetPara()->GetReformat() shows the deleted text range, and that it matches the still visible portions in GetMergedPara() - if this looks correct, the problem is in the formatting - if it looks wrong, the problem is before, in (missing) invalidations

* SwTextFrame::SwClientNotify should receive invalidations

* SwTextFormatter::BuildPortions contains a loop that builds the text portions (SwLinePortion subclasses) for a single line of text (SwLineLayout)

* see this article for some docs on the text formatting
  https://wiki.openoffice.org/wiki/Writer/Text_Formatting
Comment 6 Commit Notification 2022-04-29 19:01:23 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/515bf5d4afa3a8ed413fd6f17f66fa98b6dbf29e

tdf#148683 sw: fix crash on deleting text with redlining enabled, but hidden

It will be available in 7.4.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 7 Commit Notification 2022-05-02 10:18:57 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "libreoffice-7-3":

https://git.libreoffice.org/core/commit/571e546bcc76e21f16a9f2929caa48c7abd8055a

tdf#148683 sw: fix crash on deleting text with redlining enabled, but hidden

It will be available in 7.3.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 8 Commit Notification 2022-05-03 19:12:34 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "libreoffice-7-2":

https://git.libreoffice.org/core/commit/3b539b30c3a6559d6b4cf32c2b02fc5d81a0b794

tdf#148683 sw: fix crash on deleting text with redlining enabled, but hidden

It will be available in 7.2.8.

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 Commit Notification 2022-05-06 10:33:47 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "libreoffice-7-2-7":

https://git.libreoffice.org/core/commit/01e587b4888e12f38ed66f6057e00dbceec025bb

tdf#148683 sw: fix crash on deleting text with redlining enabled, but hidden

It will be available in 7.2.7.

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 10 Telesto 2022-05-17 23:44:27 UTC
Assert is gone
Version: 7.4.0.0.alpha1+ / LibreOffice Community
Build ID: 7e2d26ef0ed47bf01d7396aa7c749062f9bdde98
CPU threads: 8; OS: Mac OS X 12.3.1; UI render: Skia/Metal; VCL: osx
Locale: nl-NL (nl_NL.UTF-8); UI: en-US
Calc: threaded