Bug 129553 - Assert replacing in a specific text
Summary: Assert replacing in a specific text
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.2.0.3 release
Hardware: All All
: medium normal
Assignee: Michael Stahl (allotropia)
URL:
Whiteboard: target:7.0.0 target:6.4.2 target:6.3.6
Keywords: regression
Depends on:
Blocks: Crash-Assert redlinehide-regressions
  Show dependency treegraph
 
Reported: 2019-12-22 18:15 UTC by Mike Kaganski
Modified: 2020-11-19 11:08 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Text which crashes Writer on replace (64.10 KB, text/plain)
2019-12-22 18:15 UTC, Mike Kaganski
Details
bt with debug symbols (11.58 KB, text/plain)
2019-12-22 22:14 UTC, Julien Nabet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2019-12-22 18:15:58 UTC
Created attachment 156734 [details]
Text which crashes Writer on replace

1. Open attached file in Writer
2. Ctrl+H
3. Find: $
4. Replace with empty string; enable regular expressions
5. Replace All

In current master, it shows an assertion; trying to ignore it shows another one, then LibreOffice crashes.

---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Debug Error!

Program: C:\lo\src\core\instdir\program\soffice.bin

abort() has been called

(Press Retry to debug the application)

---------------------------
Abort   Retry   Ignore   
---------------------------


Tested with Version: 6.5.0.0.alpha0+ (x64)
Build ID: 876afccc7be4c708bd51f5892bdf9edec6820ea9
CPU threads: 12; OS: Windows 10.0 Build 18363; UI render: Skia/Raster; VCL: win; 
Locale: ru-RU (ru_RU); UI-Language: en-US
Calc: CL

This likely depends on first paragraph's length - more than 64 Ki characters (the text itself doesn't matter; the original was in ODT and some normal text).
Comment 1 Mike Kaganski 2019-12-22 18:55:50 UTC
Ah, the test document is irrelevant.

Create a new text document; press Enter once to have 2 empty paragraphs; replace regex $ with empty string => crash.
Comment 2 Julien Nabet 2019-12-22 22:14:56 UTC
Created attachment 156735 [details]
bt with debug symbols

On pc Debian x86-64 with master sources updated today + enable-dbgutil, I got an assert.
Comment 3 Mike Kaganski 2019-12-23 05:26:03 UTC
Michael: could you please take a look?

The SwTextFrame::MapModelToViewPos code with the assert that own node must be passed to the function was added in https://git.libreoffice.org/core/+/c5abcfdf0c2e98c8f3445a92dd2d71eab23a7268 "sw_redlinehide: add TextFrameIndex type & SwTextFrame mapping functions" (2018-06-08).

The two calls to the function from ReplaceBackReferences were added in https://git.libreoffice.org/core/+/5e81b966778d82692b4763d892b457186a7f269d "sw_redlinehide_4b: FindText() adapt the replace part as well" (2018-12-18). And the calls are guaranteed to pass a node other than the frame's node: they are made for a PaM that must start at end of a previous paragraph, and end at beginning of the next - for single "$" regex that is treated specially: see [1].

Simply commenting out the assert "solves" the problem. And release builds don't give crashes here (so I initially thought it's a regression in master, but now I suspect it only happens in debug builds). Could you see if this is OK, or does it actually violates some of your assumptions in the code?

[1] https://help.libreoffice.org/latest/en-US/text/shared/01/02100001.html
Comment 4 Xisco Faulí 2019-12-23 10:21:41 UTC
Not reproducible in

Version: 6.5.0.0.alpha0+
Build ID: 0322a41224a7264bbe03a068647ab093bcc88f90
CPU threads: 4; OS: Linux 4.15; UI render: default; VCL: gtk3; 
Locale: ca-ES (ca_ES.UTF-8); UI-Language: en-US
Calc: threaded
Comment 5 Xisco Faulí 2019-12-26 12:04:20 UTC
(In reply to Julien Nabet from comment #2)
> Created attachment 156735 [details]
> bt with debug symbols
> 
> On pc Debian x86-64 with master sources updated today + enable-dbgutil, I
> got an assert.

Moving to NEW
Comment 6 Michael Stahl (allotropia) 2020-02-19 17:51:35 UTC
fixed on master
Comment 7 Commit Notification 2020-02-19 17:52:38 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/83122add64ecbf0fd3ba30368d5d87bde3dac278

tdf#129553 sw_redlinehide: fix replace of paragraph breaks with $

It will be available in 7.0.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 2020-02-20 13:13:19 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/796aeeb0f4c26824f3477b45e0d3bae9cf2c4648

tdf#129553 sw_redlinehide follow-up: simplify ReplaceBackReferences()

It will be available in 7.0.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 9 Commit Notification 2020-02-25 09:43:02 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-6-4":

https://git.libreoffice.org/core/commit/988383d3dce56536082a639d5a8b0cc0a23da7c4

tdf#129553 sw_redlinehide: fix replace of paragraph breaks with $

It will be available in 6.4.2.

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 Commit Notification 2020-02-25 14:36:33 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-6-3":

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

tdf#129553 sw_redlinehide: fix replace of paragraph breaks with $

It will be available in 6.3.6.

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.