Bug 141689 - Crash with trendline using moving average with 2 points and type central
Summary: Crash with trendline using moving average with 2 points and type central
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
(earliest affected)
Hardware: All All
: medium normal
Assignee: Samuel Mehrbrodt (allotropia)
Whiteboard: target:7.2.0
Keywords: haveBacktrace
Depends on:
Reported: 2021-04-14 14:18 UTC by Heiko Tietze
Modified: 2021-04-15 08:29 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:

gdb bt (15.97 KB, text/plain)
2021-04-14 17:24 UTC, Julien Nabet
Test case (14.33 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-04-15 06:22 UTC, Heiko Tietze

Note You need to log in before you can comment on or make changes to this bug.
Description Heiko Tietze 2021-04-14 14:18:05 UTC
As in the title, works with 3 points or 2 prior.

In function:
    std::__debug::vector::reference std::__debug::vector<double, 
    [_Tp = double, _Allocator = std::allocator<double>]

Error: attempt to subscript container with out-of-bounds index 1, but 
container only holds 1 elements.

Objects involved in the operation:
    sequence "this" @ 0x0x55d8ea1a98b0 {
      type = std::__debug::vector<double, std::allocator<double> >;

To test, create a line chart, add a trend line, and set the parameter as given.
Comment 1 Julien Nabet 2021-04-14 17:24:29 UTC
Created attachment 171206 [details]
gdb bt

On pc Debian x86-64 with master sources updated today, I could reproduce this.

I attached a bt with some gdb.
Comment 2 Julien Nabet 2021-04-14 17:28:17 UTC
Samuel: noticing https://cgit.freedesktop.org/libreoffice/core/commit/?id=a9b71098845edcb4f6b4629795168d174f28ef70

author	Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>	2021-03-09 09:44:24 +0100
committer	Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>	2021-03-10 08:37:59 +0100
commit a9b71098845edcb4f6b4629795168d174f28ef70 (patch)
tree 5c65be57ca1b8b55794e617460ee7e06bb9cf50d
parent 96388e5e809a48573970df9b6b2649517a08447f (diff)
tdf#133423 Fix 'central' formula for moving average
Comment 3 Julien Nabet 2021-04-14 17:49:27 UTC
I'm trying to follow the code reading https://docs.oasis-open.org/office/OpenDocument/v1.3/cs02/part3-schema/OpenDocument-v1.3-cs02-part3-schema.html#property-chart_regression-moving-type, I don't understand
why we calculate "yAvg" whereas it talks about "averaged-abscissa" ; I would have expected "xAvg" since (abscissa corresponds to "x"). Did I miss something?
Comment 4 Samuel Mehrbrodt (allotropia) 2021-04-15 05:41:49 UTC
Can you please attach a bugdoc? I can't reproduce this currently.
Comment 5 Heiko Tietze 2021-04-15 06:22:35 UTC
Created attachment 171211 [details]
Test case

Just set Period to 2 and see it crash on Okay.
Comment 6 Samuel Mehrbrodt (allotropia) 2021-04-15 06:43:24 UTC
Proposed fix: https://gerrit.libreoffice.org/c/core/+/114121
Comment 7 Commit Notification 2021-04-15 08:27:44 UTC
Samuel Mehrbrodt committed a patch related to this issue.
It has been pushed to "master":


tdf#141689 Fix crash in 'Central' moving avg function

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

Affected users are encouraged to test the fix and report feedback.