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
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.2.0.0.alpha0+
Hardware: All All
: medium normal
Assignee: Samuel Mehrbrodt (allotropia)
URL:
Whiteboard: target:7.2.0
Keywords: haveBacktrace
Depends on:
Blocks:
 
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:


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

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.

/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../include/c++/10.2.0/debug/vector:427:
In function:
    std::__debug::vector::reference std::__debug::vector<double, 
    std::allocator<double>>::operator[](std::__debug::vector::size_type) 
    [_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":

https://git.libreoffice.org/core/commit/a6066989f7d346d0d43f8db46b12786546f769e8

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:
https://wiki.documentfoundation.org/Testing_Daily_Builds

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