Bug 114635 - Critical: endless loop after opening a file from kspread 1.3.5
Summary: Critical: endless loop after opening a file from kspread 1.3.5
Status: RESOLVED FIXED
Alias: None
Product: calligrasheets
Classification: Applications
Component: general (show other bugs)
Version: 1.5
Platform: Gentoo Packages Linux
: NOR major
Target Milestone: ---
Assignee: Ariya Hidayat
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-18 21:41 UTC by Frank Pieczynski
Modified: 2007-08-04 21:18 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
provocate endless loop (11.17 KB, application/x-kspread)
2005-10-18 21:43 UTC, Frank Pieczynski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Frank Pieczynski 2005-10-18 21:41:11 UTC
Version:           1.4.2 (using KDE KDE 3.4.1)
Installed from:    Gentoo Packages
Compiler:          gcc 3.4.3 
OS:                Linux

After opening a complex kspread document with lot's of formulas kspread hangs at opening and running in an endless loop. Since the file contains private data I go back to 1.3.5 and tried to made the document smaller and tried it again in the new version.
Now I have a much smaller file, it behaves a little bit different, but definitly run into a problem. kspread 1.4.2 can open the file, but if you try to scroll in it using the mouse wheel kspread goes into an endless loop, no GUI updates anymore.
The problem seems to be related to formulas, but both documents (the original big one and the small) are working without problems in 1.3.5. No loops are in formulas.
So do not wonder about the sheet, it's useless - only for reproducing the bug :-)

The system is a 64bit Gentoo, if this is interesting.
Comment 1 Frank Pieczynski 2005-10-18 21:43:07 UTC
Created attachment 13045 [details]
provocate endless loop
Comment 2 Roland 2005-11-03 20:48:08 UTC
I can reproduce this (kspread 1.4.2, on use Suse9.3)
Comment 3 Frank Pieczynski 2005-11-23 22:44:13 UTC
Thanks to David's fix in kspread_cell.cc this bug is solved now, great.
Comment 4 Frank Pieczynski 2006-05-12 21:28:34 UTC
This happens again in kspread 1.5.0
I run again into problems with my documents. Remembering this bug I tried again to open the attached test document from october - loops again.
This was fixed in between (in some 1.5.0rc).
Comment 5 David Faure 2006-05-12 21:35:03 UTC
This bug report is confusing now ;)

I guess my commit mentionned here was this one:

"SVN commit 516143 by dfaure:
DependencyManager::cellChanged was calling DependencyList::cellChanged but was also doing exactly the same thing. As a result, http://kdab.net/~dfaure/dependencies.ods
would recalculate dependencies for a -very- long time when changing the value of A1."
Comment 6 Frank Pieczynski 2006-05-12 22:02:38 UTC
No David, at that time this bug was fixed with this change:
Revision 482318 
 Modified Tue Nov 22 16:23:13 2005 UTC (5 months, 2 weeks ago) by dfaure 
Fixed infinite loop [or massive slowdown?] in my large spreadsheet, due to setValue() always emitting 'changed'
even when nothing changed, so the dependencies were recalculated, over and over again.

Ariya informed me about this fix, and after retesting I closed it.
It's somehow important for me, I can only use 1.3.5 for those problematic sheets.
Comment 7 Frank Pieczynski 2006-05-21 01:04:23 UTC
I checked the history of kspread_cell.cc

After Davids fix in Nov 22 (version 482318) in void Cell::setValue( const Value& v )
 if ( d->value == v )
     return;
there was a change again at this place (revision 506824), made by author 'knight' on Feb 7:
 if ( ( d->value == v ) && ( !isFormula() ) )
     return;

This causes again the endless loops.

If I revert the second change (compiled 1.5.1), I can edit my existing sheets again.
Also the attached example in this bug report can be opened without going into loop.
But removing this check means some other things are not fixed. How to handle this issue right?
Comment 8 Robert Knight 2006-05-29 20:48:02 UTC
Hi,

The commit that inadvertantly introduced this bug fixed another serious bug, so it wouldn't be a good idea to just revert that particular commit.

I have very little time from now until mid-June, so unless someone else fixes this, the patch will probably end up in the 1.6x branch.

See the relevant commit log below:

=====

SVN commit 506824 by knight:

Fix bug where changing a cell containing a formula did not update that cell's dependancies if the result of evaluating that formula was equal to the result of evaluating the previously contained formula.  This fixes the issue where entering formulae such as =<CELL X> did not update cell dependancies if <CELL X> was empty at the time the forumla was entered.

 M  +7 -1      kspread_cell.cc


--- trunk/koffice/kspread/kspread_cell.cc #506823:506824
@@ -484,7 +484,13 @@
  if (v.type() != Value::Error)
    clearAllErrors();

-  if ( d->value == v )
+  //If the value has not changed then we don't need to do anything
+  //(ie. no need to relayout, update dependant cells etc.),
+  //unless this cell contains a formula, in which case its dependancies might have changed
+  //even though the value has not.  For example, if this cell was previously empty (and its value is
+  //therefore empty) and a new dependency upon an empty cell has been added.  The new value would still
+  //be empty, but the dependencies need to be updated (via the call to valueChanged() below).
+  if ( ( d->value == v ) && ( !isFormula() ) )
    return;

  d->value = v;
Comment 9 Frederik Schwarzer 2006-06-02 02:52:03 UTC
I had I similar think today and it ended up in a file where I could not insert lines anymore. I reported it and attached the file. => https://bugs.kde.org/show_bug.cgi?id=128470
Comment 10 Sebastian Sauer 2006-08-03 00:49:18 UTC
Bugreport #128470 is not related since there the attached document defines 32k rows, does not freez KSpread and KSpread even fixes the document once saved. This report seems to be about a circular refresh or something like this (not reproducable for me with KSpread 1.6 :-/ ).
Comment 11 Stefan Nikolaus 2006-08-03 08:55:58 UTC
#Sebastian: You have alter the first non-formula cell or hit F9 to recalculate.
Comment 12 Sebastian Sauer 2006-08-19 16:44:22 UTC
Ah. Ok. Changing the first non-formular cell freezes KSpread even with a today from the 1.6-branch compiled version.

Backtrace;
#0  0xb6edd1fa in operator< () from /usr/lib/libqt-mt.so.3
#1  0xb61e3da3 in KSpread::Point::init (this=0xbfa7b7b4, _str=@0xbfa7b714) at kspread_util.cc:276
#2  0xb61e48d6 in Point (this=0xbfa7b7b4, str=@0xbfa7b7ec, map=0x835c0b8, sheet=0x8338d88)
    at kspread_util.cc:418
#3  0xb607d6a2 in KSpread::Formula::eval (this=0x84bbf98) at formula.cc:1356
#4  0xb60d0a5d in KSpread::Cell::calc (this=0x84b8ff8, delay=false) at kspread_cell.cc:2107
#5  0xb606dcb1 in KSpread::DependencyList::updateCell (this=0x81c3e00, cell=@0x82cbc50)
    at dependencies.cc:589
#6  0xb606e310 in KSpread::DependencyList::processDependencies (this=0x81c3e00, cell=@0xbfa7bc30)
    at dependencies.cc:466
#7  0xb606f4df in KSpread::DependencyList::cellChanged (this=0x81c3e00, cell=@0xbfa7bc30)
    at dependencies.cc:227
#8  0xb606f50c in KSpread::DependencyManager::cellChanged (this=0x834d098, cell=@0xbfa7bc30)
    at dependencies.cc:169
#9  0xb61b4991 in KSpread::Sheet::valueChanged (this=0x8338d88, cell=0x84bc0c8) at kspread_sheet.cc:1288
#10 0xb60b8bf7 in KSpread::Cell::valueChanged (this=0x84bc0c8) at kspread_cell.cc:1578
#11 0xb60bbf25 in KSpread::Cell::setValue (this=0x84bc0c8, v=@0xbfa7bccc) at kspread_cell.cc:510
#12 0xb60d0a72 in KSpread::Cell::calc (this=0x84bc0c8, delay=false) at kspread_cell.cc:2108
#13 0xb606dcb1 in KSpread::DependencyList::updateCell (this=0x81c3e00, cell=@0x81b7c80)
    at dependencies.cc:589
#14 0xb606e310 in KSpread::DependencyList::processDependencies (this=0x81c3e00, cell=@0xbfa7bdd0)
    at dependencies.cc:466
#15 0xb606f4df in KSpread::DependencyList::cellChanged (this=0x81c3e00, cell=@0xbfa7bdd0)
    at dependencies.cc:227
#16 0xb606f50c in KSpread::DependencyManager::cellChanged (this=0x834d098, cell=@0xbfa7bdd0)
    at dependencies.cc:169
#17 0xb61b4991 in KSpread::Sheet::valueChanged (this=0x8338d88, cell=0x84bc490) at kspread_sheet.cc:1288
#18 0xb60b8bf7 in KSpread::Cell::valueChanged (this=0x84bc490) at kspread_cell.cc:1578
#19 0xb60bbf25 in KSpread::Cell::setValue (this=0x84bc490, v=@0xbfa7be6c) at kspread_cell.cc:510
#20 0xb60d0a72 in KSpread::Cell::calc (this=0x84bc490, delay=false) at kspread_cell.cc:2108
#21 0xb606dcb1 in KSpread::DependencyList::updateCell (this=0x81c3e00, cell=@0x8300df0)
    at dependencies.cc:589
#22 0xb606e310 in KSpread::DependencyList::processDependencies (this=0x81c3e00, cell=@0xbfa7bf70)
    at dependencies.cc:466
#23 0xb606f4df in KSpread::DependencyList::cellChanged (this=0x81c3e00, cell=@0xbfa7bf70)
    at dependencies.cc:227
#24 0xb606f50c in KSpread::DependencyManager::cellChanged (this=0x834d098, cell=@0xbfa7bf70)
    at dependencies.cc:169
#25 0xb61b4991 in KSpread::Sheet::valueChanged (this=0x8338d88, cell=0x84bc978) at kspread_sheet.cc:1288
#26 0xb60b8bf7 in KSpread::Cell::valueChanged (this=0x84bc978) at kspread_cell.cc:1578
#27 0xb60bbf25 in KSpread::Cell::setValue (this=0x84bc978, v=@0xbfa7c00c) at kspread_cell.cc:510
#28 0xb60d0a72 in KSpread::Cell::calc (this=0x84bc978, delay=false) at kspread_cell.cc:2108
#29 0xb606dcb1 in KSpread::DependencyList::updateCell (this=0x81c3e00, cell=@0x82e5178)
    at dependencies.cc:589
#30 0xb606e310 in KSpread::DependencyList::processDependencies (this=0x81c3e00, cell=@0xbfa7c110)
    at dependencies.cc:466
---Type <return> to continue, or q <return> to quit---
#31 0xb606f4df in KSpread::DependencyList::cellChanged (this=0x81c3e00, cell=@0xbfa7c110)
    at dependencies.cc:227
#32 0xb606f50c in KSpread::DependencyManager::cellChanged (this=0x834d098, cell=@0xbfa7c110)
    at dependencies.cc:169
#33 0xb61b4991 in KSpread::Sheet::valueChanged (this=0x8338d88, cell=0x84bd1a0) at kspread_sheet.cc:1288
#34 0xb60b8bf7 in KSpread::Cell::valueChanged (this=0x84bd1a0) at kspread_cell.cc:1578
#35 0xb60bbf25 in KSpread::Cell::setValue (this=0x84bd1a0, v=@0xbfa7c1ac) at kspread_cell.cc:510
#36 0xb60d0a72 in KSpread::Cell::calc (this=0x84bd1a0, delay=false) at kspread_cell.cc:2108
#37 0xb606dcb1 in KSpread::DependencyList::updateCell (this=0x81c3e00, cell=@0x82a85f8)
    at dependencies.cc:589
#38 0xb606e310 in KSpread::DependencyList::processDependencies (this=0x81c3e00, cell=@0xbfa7c2b0)
    at dependencies.cc:466
#39 0xb606f4df in KSpread::DependencyList::cellChanged (this=0x81c3e00, cell=@0xbfa7c2b0)
    at dependencies.cc:227
#40 0xb606f50c in KSpread::DependencyManager::cellChanged (this=0x834d098, cell=@0xbfa7c2b0)
    at dependencies.cc:169
#41 0xb61b4991 in KSpread::Sheet::valueChanged (this=0x8338d88, cell=0x84bdbe8) at kspread_sheet.cc:1288
#42 0xb60b8bf7 in KSpread::Cell::valueChanged (this=0x84bdbe8) at kspread_cell.cc:1578
#43 0xb60bbf25 in KSpread::Cell::setValue (this=0x84bdbe8, v=@0xbfa7c34c) at kspread_cell.cc:510
#44 0xb60d0a72 in KSpread::Cell::calc (this=0x84bdbe8, delay=false) at kspread_cell.cc:2108
#45 0xb606dcb1 in KSpread::DependencyList::updateCell (this=0x81c3e00, cell=@0x83ce5c8)
    at dependencies.cc:589
#46 0xb606e310 in KSpread::DependencyList::processDependencies (this=0x81c3e00, cell=@0xbfa7c450)
    at dependencies.cc:466
#47 0xb606f4df in KSpread::DependencyList::cellChanged (this=0x81c3e00, cell=@0xbfa7c450)
    at dependencies.cc:227
#48 0xb606f50c in KSpread::DependencyManager::cellChanged (this=0x834d098, cell=@0xbfa7c450)
    at dependencies.cc:169
#49 0xb61b4991 in KSpread::Sheet::valueChanged (this=0x8338d88, cell=0x84bdb58) at kspread_sheet.cc:1288
#50 0xb60b8bf7 in KSpread::Cell::valueChanged (this=0x84bdb58) at kspread_cell.cc:1578
#51 0xb60bbf25 in KSpread::Cell::setValue (this=0x84bdb58, v=@0xbfa7c4ec) at kspread_cell.cc:510
#52 0xb60d0a72 in KSpread::Cell::calc (this=0x84bdb58, delay=false) at kspread_cell.cc:2108
#53 0xb606dcb1 in KSpread::DependencyList::updateCell (this=0x81c3e00, cell=@0x82a62c8)
    at dependencies.cc:589
#54 0xb606e310 in KSpread::DependencyList::processDependencies (this=0x81c3e00, cell=@0xbfa7c5f0)
    at dependencies.cc:466
#55 0xb606f4df in KSpread::DependencyList::cellChanged (this=0x81c3e00, cell=@0xbfa7c5f0)
    at dependencies.cc:227
#56 0xb606f50c in KSpread::DependencyManager::cellChanged (this=0x834d098, cell=@0xbfa7c5f0)
    at dependencies.cc:169
#57 0xb61b4991 in KSpread::Sheet::valueChanged (this=0x8338d88, cell=0x84bdb18) at kspread_sheet.cc:1288
#58 0xb60b8bf7 in KSpread::Cell::valueChanged (this=0x84bdb18) at kspread_cell.cc:1578
#59 0xb60bbf25 in KSpread::Cell::setValue (this=0x84bdb18, v=@0xbfa7c68c) at kspread_cell.cc:510
#60 0xb60d0a72 in KSpread::Cell::calc (this=0x84bdb18, delay=false) at kspread_cell.cc:2108
#61 0xb606dcb1 in KSpread::DependencyList::updateCell (this=0x81c3e00, cell=@0x82a4380)
    at dependencies.cc:589
[...]
Comment 13 Stefan Nikolaus 2007-08-04 21:18:04 UTC
Fixed in the upcoming 2.x series.