Bug 126071 - Assertion failure in offline help viewer when searching for string starting or ending in non-alphanumeric character
Summary: Assertion failure in offline help viewer when searching for string starting o...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: framework (show other bugs)
Version:
(earliest affected)
6.4.0.0.alpha1+
Hardware: All All
: low normal
Assignee: Not Assigned
URL:
Whiteboard: target:6.4.0 target:6.3.0.1 target:6.2.6
Keywords: haveBacktrace
Depends on:
Blocks: Crash-Assert
  Show dependency treegraph
 
Reported: 2019-06-24 20:14 UTC by Gabor Kelemen (allotropia)
Modified: 2019-06-28 18:35 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Backtrace of the assertion error (22.46 KB, text/x-log)
2019-06-24 20:14 UTC, Gabor Kelemen (allotropia)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gabor Kelemen (allotropia) 2019-06-24 20:14:37 UTC
Created attachment 152373 [details]
Backtrace of the assertion error

If I try to search for a string that ends with a dot the offline help viewer crashes with an assertion error. 
In the non debug build I get a "There is no such topic" dialog when doing the same.

To reproduce:
1. Open the offline help browser.
2. Go to the Search tab.
3. Enter "foo." and press the Find button.
 
The console shows this output:

soffice.bin: /home/gabor/src/core/sal/rtl/strtmpl.cxx:1378: void rtl_uString_newFromSubString(rtl_uString**, const rtl_uString*, sal_Int32, sal_Int32): Assertion `false' failed.

Happens in:
Version: 6.4.0.0.alpha0+
Build ID: ab5f341efd144adb6b7d0e00fece76a2153acd10
CPU threads: 4; OS: Linux 4.15; UI render: default; VCL: gtk3; 
Locale: hu-HU (hu_HU.UTF-8); UI-Language: en-US
Calc: threaded

There is no assertion error when searching for "foo" or "foo.a" but there is one if searching for ".foo". 
Also this happens with basically any non alphanumeric characters at the beginning or end of the string: .,"+-%=?! all can reproduce the problematic behavior.
Comment 1 Julien Nabet 2019-06-25 12:30:22 UTC
On Win10 with master sources updated today, I could reproduce this.

Adding some traces on PrepareSearchString method in sfx2/source/appl/newhelp.cxx, I got:
before loop rSearchString=foo.
loop aBoundary.startPos=0 aBoundary.endPos=3
loop aBoundary.startPos=4 aBoundary.endPos=0
Comment 2 Julien Nabet 2019-06-25 12:43:45 UTC
This straightforward patch seems a good fix:
diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx
index 8f6ccd8af2be..8595cd436aef 100644
--- a/sfx2/source/appl/newhelp.cxx
+++ b/sfx2/source/appl/newhelp.cxx
@@ -207,7 +207,7 @@ namespace sfx2
         Boundary aBoundary = xBreak->getWordBoundary(
             rSearchString, nStartPos, aLocale, WordType::ANYWORD_IGNOREWHITESPACES, true );

-        while ( aBoundary.startPos != aBoundary.endPos )
+        while ( aBoundary.endPos && aBoundary.startPos != aBoundary.endPos )
         {
             nStartPos = aBoundary.endPos;
             OUString sSearchToken( rSearchString.copy(

Gabor: I'll be able to submit it on gerrit review only after my daytime job so if you want to give it a try or submit it to review, don't hesitate!
Comment 3 Julien Nabet 2019-06-25 16:34:33 UTC
Patch submitted to review here:
https://gerrit.libreoffice.org/#/c/74716/
Comment 4 Commit Notification 2019-06-28 13:37:27 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/+/0328e0af9532d5ab26840cf58b9dcbb69bb8c33d%5E%21

tdf#126071: fix assertion with offline help viewer

It will be available in 6.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 5 Julien Nabet 2019-06-28 13:39:45 UTC
Patches on gerrit review
for 6.3: https://gerrit.libreoffice.org/#/c/74845/
for 6.2: https://gerrit.libreoffice.org/#/c/74846/
Comment 6 Commit Notification 2019-06-28 14:42:06 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-6-3":

https://git.libreoffice.org/core/+/03ef64befed26a03b35d6e977649face888f41a5%5E%21

tdf#126071: fix assertion with offline help viewer

It will be available in 6.3.0.1.

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 2019-06-28 18:35:58 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-6-2":

https://git.libreoffice.org/core/+/cb1c5ae7af997d7643da97235caf95789ba09416%5E%21

tdf#126071: fix assertion with offline help viewer

It will be available in 6.2.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.