Issue 107693 - Calc crashes when referencing entire external sheet
Summary: Calc crashes when referencing entire external sheet
Status: ACCEPTED
Alias: None
Product: Calc
Classification: Application
Component: editing (show other issues)
Version: OOo 3.1.1
Hardware: Unknown All
: P2 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on: 109169 109168
Blocks:
  Show dependency tree
 
Reported: 2009-12-15 13:53 UTC by daniel.rentz
Modified: 2013-08-07 15:13 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description daniel.rentz 2009-12-15 13:53:24 UTC
Open a new Calc sheet and save somewhere.
Open a second new Calc sheet, and in A1 enter "=SUM(" then select an entire
sheet of the first document.
Hit Enter.

Calc exits with a bad_alloc after allocating >1.7GB of heap memory. This is
because all empty cells are stored in the external reference cache.
Comment 1 kyoshida 2009-12-15 14:30:59 UTC
My goodness.  Did someone try to select an entire sheet (again) !?  ;-)

I'll look into it.
Comment 2 daniel.rentz 2009-12-15 14:36:28 UTC
I did this to try out my fix for issue 107439 -- where the Excel export filter
writes out the same external value again and again for every cell formula that
uses this value. I added an optimization to leave out empty cells (which is what
Excel does too). This helps to prevent huge files for formulas with big external
references to empty ranges.
Comment 3 kyoshida 2009-12-15 14:47:02 UTC
Gotcha.  Either way this needs to be fixed.
Comment 4 kyoshida 2010-02-08 16:27:27 UTC
I'm working on this in kohei04 cws right now.
Comment 5 kyoshida 2010-02-09 21:23:14 UTC
Actually, this task is getting large enough that I'd like to use a separate CWS
for this.  Taking this off of kohei04's task list.
Comment 6 kyoshida 2010-02-10 16:18:41 UTC
To get this one right, I need to rework ScMatrix class itself, to add a new type
of matrix that's sparsely populated i.e. most of its elements are empty.  I'm
working on that right now.
Comment 7 kyoshida 2010-02-10 16:27:22 UTC
I think that, by moving the current value-optimized matrix implementation code
into its own impl class, and making it swappable with another backend
implementation, we can probably support both the existing number-optimized
matrices alongside the new sparsely populated ones, with minimal disruption in
the existing code that uses ScMatrix class.
Comment 8 niklas.nebel 2010-02-10 16:45:40 UTC
Really? More changes to basic classes? How useful is this case anyway, shouldn't
we just set an error if ScMatrix::GetElementsMax is exceeded?
Comment 9 kyoshida 2010-02-10 17:02:41 UTC
What I need is to build a legitimate matrix that only has a few cells filled. 
We can't throw an error at those matrices since they are valid matrices.  This
is done for performance reasons, which I assume is useful.
Comment 10 kyoshida 2010-02-10 17:04:33 UTC
BTW, other matrix implementations also support multiple backends depending on
the nature of stored data.  boost ublas is one such implementation.  So, it's
not unreasonable to have multiple backends for the matrix class.  It's actually
a necessity if you care about performance of matrix-related computations.
Comment 11 niklas.nebel 2010-02-10 17:21:32 UTC
And then we're back to adjusting sumif or dsum again? External references could
become an endless story, and I want to avoid that.
Comment 12 kyoshida 2010-02-10 18:03:16 UTC
Ok.  You clearly don't understand what I'm trying to do.  I'll only modify how
the matrix elements are stored.  This won't alter the behavior of the matrix
class, hence no adjustment is necessary in the client code.  Period.

BTW, what do you mean by the endless story?  Do you want me to back off of this
so that you can fix all this mess on your own?
Comment 13 niklas.nebel 2010-02-11 08:55:24 UTC
I would like to see a fix that doesn't cause new problems. A small fix is much
more likely to achieve this.

If we want to change the matrix implementation, we can do it in a separate step,
with enough testing, without the haste of fixing this regression.
Comment 14 kyoshida 2010-02-11 16:28:10 UTC
>A small fix is much more likely to achieve this.

Likely, yes, but not always.  There are times when you need to make a
non-trivial change, to fix the underlying design mistake or do things the right
way without resorting to many small hacks.  This is unfortunately one such case.

>If we want to change the matrix implementation, we can do it in a separate
step, with enough testing, without the haste of fixing this regression.

Fair enough.  But without the change in the matrix implementation I can only fix
this issue partially.  So, I will leave this one open and file another issue, to
incorporate the partial fix that only involves change in the external ref manager.
Comment 15 kyoshida 2010-02-11 16:28:45 UTC
Re-targeting.
Comment 16 Rob Weir 2013-07-30 02:37:54 UTC
Reset assignee on issues not touched by assignee in more than 1000 days.