Bug 77516 - Crash when setting sub-grid to 0
Summary: Crash when setting sub-grid to 0
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.2.2.1 release
Hardware: Other All
: high major
Assignee: Caolán McNamara
URL:
Whiteboard: BSA target:4.4.0 target:4.2.7 target:...
Keywords: bibisectRequest, haveBacktrace, regression
: 80609 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-04-16 08:43 UTC by jr4air
Modified: 2015-12-17 07:56 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
sub-grid number is 0. (120.72 KB, image/png)
2014-04-16 08:43 UTC, jr4air
Details
bt with symbols (7.28 KB, text/plain)
2014-04-17 20:40 UTC, Julien Nabet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jr4air 2014-04-16 08:43:54 UTC
Created attachment 97457 [details]
sub-grid number is 0.

Problem description: Crash when setting sub-grid.

Steps to reproduce:
1. Writer-option-LibreOfficeWiter
2. grid-subgrid- number 0 Ok crash
3. Recovery operation OK crash
Current behavior: Endless loop during autosave

Expected behavior: repair
Operating System: Windows 7
Version: 4.2.2.1 release
Comment 1 Julien Nabet 2014-04-17 20:40:52 UTC
Created attachment 97533 [details]
bt with symbols

On pc Debian x86-64 with master sources updated yesterday, I could reproduce this.
Comment 2 Julien Nabet 2014-04-28 21:40:39 UTC
Michael: would you have some time to give your opinion about this?
Indeed, I thought about 2 ways (perhaps there are others)
1) put a minimum to 1 for subdivisionX/Y so we're sure there's no problem (but how to do this?)
2) Investigating the code, here what I found:
rOpt.GetDivisionX/Y() return -1 if 0 has been selected on UI because the values come from this part:
   359         short nDiv = (short)pGridItem->GetFldDivisionX() ;
   360         if( aViewOpt.GetDivisionX() != nDiv  )
   361             aViewOpt.SetDivisionX( nDiv );
   362         nDiv = (short)pGridItem->GetFldDivisionY();
   363         if( aViewOpt.GetDivisionY() != nDiv  )
   364             aViewOpt.SetDivisionY( nDiv  );
in sw/source/core/uibase/app/appopt.cxx (see http://opengrok.libreoffice.org/xref/core/sw/source/core/uibase/app/appopt.cxx#359)

then http://opengrok.libreoffice.org/xref/core/svx/source/dialog/optgrid.cxx#211 show this:
    211         aGridItem.nFldDivisionX = static_cast<long>(pNumFldDivisionX->GetValue()-1);
    212         aGridItem.nFldDivisionY = static_cast<long>(pNumFldDivisionY->GetValue()-1);

So I don't know the reason of all this but this simple patch could make it:
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index b46d071..31d2fda 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -2149,8 +2149,8 @@ void SwViewShell::ImplApplyViewOptions( const SwViewOption &rOpt )
         pDView->SetGridCoarse( rSz );
 
         const Size aFSize
-            ( rSz.Width() ? rSz.Width() / (rOpt.GetDivisionX()+1) : 0,
-              rSz.Height()? rSz.Height()/ (rOpt.GetDivisionY()+1) : 0);
+            ( (rSz.Width() && rOpt.GetDivisionX() != -1) ? rSz.Width() / (rOpt.GetDivisionX()+1) : 0,
+              (rSz.Height() && rOpt.GetDivisionY() != -1)? rSz.Height()/ (rOpt.GetDivisionY()+1) : 0);
I tested it, it doesn't crash but has it a meaning?
Comment 3 Harald Koester 2014-08-09 16:51:25 UTC
Bug tested with different versions:
3.6.7: OK
4.1.5: OK
4.2.0: Crash
4.3.0: Crash

Hence regression.
Comment 4 Julien Nabet 2014-08-14 20:43:19 UTC
Thank you Harald for this piece of information.
I add regression on keywords and increase the importance.

BTW, I still reproduce the problem with master sources updated today.
Comment 5 ign_christian 2014-08-15 02:41:37 UTC
Set platform All per comment 1

Add bibisectRequest to Whiteboard per Bug 82632
Comment 6 Commit Notification 2014-08-28 08:52:08 UTC
Caolan McNamara committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=4bd317f845c2f3470c7fc354e478be08c2949e0c

Resolves: fdo#77516 sub-grid shouldn't be allowed as 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 7 Commit Notification 2014-08-28 10:00:58 UTC
Caolan McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-4-2":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=d557b1e7c998b3895fde7236c1a2d8e0998922c5&h=libreoffice-4-2

Resolves: fdo#77516 sub-grid shouldn't be allowed as 0


It will be available in LibreOffice 4.2.7.

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 8 Commit Notification 2014-08-28 10:04:57 UTC
Caolan McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-4-3":

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

Resolves: fdo#77516 sub-grid shouldn't be allowed as 0


It will be available in LibreOffice 4.3.2.

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 9 Ken Biondi 2014-09-06 03:58:27 UTC
I verified this fix in the three versions below. Changed status to verified.

Version: 4.3.2.0.0+
Build ID: 233e6a62d12d2d67089f1934777ac41c9fc88238
TinderBox: Win-x86@42, Branch:libreoffice-4-3, Time: 2014-09-05_11:10:36

Version: 4.2.7.0.0+
Build ID: fef72d750ea29dd3368f2e5f3099bb81e22ab07c
TinderBox: Win-x86@42, Branch:libreoffice-4-2, Time: 2014-09-05_17:30:54

Version: 4.4.0.0.alpha0+
Build ID: 040a59e513b6435fb39bfecad9a54b3283216d0e
TinderBox: Win-x86@42, Branch:master, Time: 2014-09-04_23:21:24
Comment 10 Katarina Behrens 2014-10-06 20:25:21 UTC
*** Bug 80609 has been marked as a duplicate of this bug. ***
Comment 11 Robinson Tryon (qubit) 2015-12-17 07:56:54 UTC Comment hidden (obsolete)