Bug 155825

Summary: Crash MCGR export special file odp -> pptx
Product: LibreOffice Reporter: Regina Henschel <rb.henschel>
Component: ImpressAssignee: Regina Henschel <rb.henschel>
Status: RESOLVED FIXED    
Severity: normal CC: Armin.Le.Grand, caolan.mcnamara
Priority: medium    
Version: unspecified   
Hardware: x86-64 (AMD64)   
OS: Windows (All)   
Whiteboard: target:24.2.0 target:7.6.0.0.beta2
Crash report or crash signature: Regression By:
Attachments: Callstack by Visual Studio
reduced example
axial color mixed with linear transparency

Description Regina Henschel 2023-06-13 20:36:39 UTC
Created attachment 187897 [details]
Callstack by Visual Studio

I could reproduce the crash mentioned in https://gerrit.libreoffice.org/c/core/+/152673 for normal, not headless export. The callstack from Visual Studio is attached.

The crash happen in oox/source/export/drawingml.cxx in
    if (aColorStops.size() != aAlphaStops.size() || nullptr == pGradient)
    {
        // this is an error - synchronizeColorStops above *has* to create that
        // state, see description there (!)
        // also an error - see comment in header - is to give neither pColorGradient
        // nor pTransparenceGradient
        assert(false && "oox::WriteGradientFill: non-synchronized gradients (!)");
        return;
    }
Comment 1 Regina Henschel 2023-06-13 22:38:29 UTC
Created attachment 187900 [details]
reduced example

The error is in synchronizeColorStops in gradienttools.cxx in lines 440 to 454.

In both cases not only aNewAlpha (or aNewColor respectively), has to get the stop but aNewColor (or aNewAlpha respectively) too. The both aNew... need to grow simultaneously.

The situation in the example is, that the offsets for the colors are 0 and 0.9, and for the transparency 0 and 1. The generated aNewColor and aNewAlpha both need the stops 0, 0.9 and 1.

[Looking at the code, I'm not sure whether the combination of axial and linear is handled correctly. (In the following the Number is the offset and the characters are the values.)
Imagine a axial color gradient with 0 A, 1 B together with a linear transparency gradient 0 X, 1 Y. Then the resulting stops should be 0 BX, 0.5 A middle_of_XY, 1 BY. But because you apply axial after synchronizing you get 0 BY, 0.5 AX, 1 BY.
But I'm not sure and its after midnight so would need to look at it tomorrow again.]
Comment 2 Regina Henschel 2023-06-13 22:56:09 UTC
Created attachment 187901 [details]
axial color mixed with linear transparency

Axial plus linear is indeed a problem. The attached file has a shape with both gradients with stops at offset 0 and 1 (so do not trigger the crash) and a screenshot of the shape. Save the file to pptx and open the pptx-file. You see the error immediately.
Comment 3 Regina Henschel 2023-06-14 08:37:52 UTC
I have written bug 155827 for the axial-linear problem. It is independent from the crash here.
Comment 4 Regina Henschel 2023-06-14 11:51:26 UTC
I'll work on it.
Comment 5 Commit Notification 2023-06-14 19:30:49 UTC
Regina Henschel committed a patch related to this issue.
It has been pushed to "master":

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

tdf155825 result same size in synchronize gradients

It will be available in 24.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.
Comment 6 Commit Notification 2023-06-16 08:26:04 UTC
Regina Henschel committed a patch related to this issue.
It has been pushed to "libreoffice-7-6":

https://git.libreoffice.org/core/commit/6ce0ba0c94e137a7b3e0ddd0634c9b545eb2b9f0

tdf155825 result same size in synchronize gradients

It will be available in 7.6.0.0.beta2.

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.