Bug 145843 - Incidental Crash on macOS with skia raster (STR comment 8)
Summary: Incidental Crash on macOS with skia raster (STR comment 8)
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.3.0.0 alpha0+
Hardware: All macOS (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:7.5.0 target:7.4.0.0.beta2 tar...
Keywords:
: 147302 147563 147638 (view as bug list)
Depends on:
Blocks: macOS-UI-polish Skia
  Show dependency treegraph
 
Reported: 2021-11-23 00:48 UTC by Telesto
Modified: 2022-12-19 11:28 UTC (History)
10 users (show)

See Also:
Crash report or crash signature:


Attachments
BT with symbols ( (8.10 KB, text/rtf)
2021-11-23 00:49 UTC, Telesto
Details
BT with symbols (5.51 KB, application/vnd.oasis.opendocument.text)
2022-01-28 21:16 UTC, Telesto
Details
Original patch (1.42 KB, patch)
2022-07-03 01:59 UTC, Telesto
Details
Debug patch (954 bytes, patch)
2022-12-14 04:38 UTC, Telesto
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Telesto 2021-11-23 00:48:35 UTC
Description:
Incidental Crash on macOS with skia raster

Steps to Reproduce:
1. Open attachment 150226 [details] with debugger lldb attached
2. Scroll down to bottom
3. LibreOffice  -> about
4. Press copy about button -> crash

Actual Results:
Crash

Expected Results:
no crash


Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 7.3.0.0.alpha1+ / LibreOffice Community
Build ID: 11800469cc7b3a40c42410be93a12e5107db0efb
CPU threads: 8; OS: Mac OS X 10.16; UI render: Skia/Raster; VCL: osx
Locale: nl-NL (nl_NL.UTF-8); UI: en-US
Calc: threaded
Comment 1 Telesto 2021-11-23 00:49:11 UTC
Created attachment 176437 [details]
BT with symbols (
Comment 2 Luboš Luňák 2021-11-30 10:37:01 UTC
I cannot reproduce.
Comment 3 Telesto 2021-11-30 13:22:32 UTC
(In reply to Luboš Luňák from comment #2)
> I cannot reproduce.

Hmm, pretty sure there is something bug 120727 comment 39 has the same experience.
Based on the BT I would say its bit of a timing problem: SkiaFlushIdle

    frame #6: 0x0000000104d5e0e7 libvcllo.dylib`SkiaSalGraphicsImpl::performFlush() + 215
    frame #7: 0x0000000104d71442 libvcllo.dylib`SkiaFlushIdle::Invoke() + 18
    frame #8: 0x0000000104b85765 libvcllo.dylib`Scheduler::CallbackTaskScheduling() + 4773
    frame #9: 0x0000000106d36197 libvclplug_osxlo.dylib`AquaSalTimer::callTimerCallback() 

Another speculative one:
1. Open Writer
2. Open second Window
3. Go the first LibreOffice -> About -> press copy about button
4. Go to the second window & paste
5. Go again LibreOffice -> About -> press copy button (freeze)


@Steve
Any luck to reproducing this? Is bit of an erratic crash :-(
Comment 4 Telesto 2021-12-01 07:57:25 UTC
1. Open LibreOffice (Start Center)
2. Writer document
3. Help -> Restart in safe mode
4. Cancel
5. LibreOffice About. Press copy button
6. Close dialog
7. LibreOffice About. Press copy button
8. Help -> Restart in safe mode
9. Switch to different app and back
10. Cancel dialog
11. LibreOffice About. Press copy button

Crash should occur somewhere in this dance. Sometimes it crashes instant, other times it takes a little longer
Comment 5 steve 2021-12-01 13:42:36 UTC
Unable to reproduce.

Unsure about step "8. Help -> Restart in safe mode", are you actually restarting?  Since previously you specify "cancel" but don't indicate how to proceed this time around.

Version: 7.4.0.0.alpha0+ / LibreOffice Community
Build ID: 4ac9032163cf55c160145373e7c41741c9c339ca
CPU threads: 8; OS: Mac OS X 10.16; UI render: Skia/Metal; VCL: osx
Locale: de-DE (en_DE.UTF-8); UI: en-US
Calc: threaded

But then again I am not sure how to switch to "Skia/Raster". I see "Skia/Metal" in about. So I might be holding it wrong (TM)?
Comment 6 Telesto 2021-12-01 15:33:44 UTC
(In reply to steve from comment #5)
> But then again I am not sure how to switch to "Skia/Raster". I see
> "Skia/Metal" in about. So I might be holding it wrong (TM)?

Well Metal won't crash... Needs to be Raster: LibreOffice -> Preferences - View -> Force Skia Raster

Regarding to the dance. No I didn't press Restart in safe-mode.. It has something to do with dialogs causing a crash out of the sudden. I have narrowed it down (but it isn't exact on timing). It does crash within the minute toying around with about/safe-mode dialog (so on my system regularly)
Comment 7 Telesto 2021-12-01 15:34:24 UTC
And well, I forgot, thanks for testing..
Comment 8 Telesto 2021-12-01 15:50:22 UTC
Straight forward crasher:
1. Open soffice (so start center)
2. Click Impress (assuming the wizard enabled)
3. Double click on the slides panel (with wizard still on top) -> crash

Version: 7.4.0.0.alpha0+ / LibreOffice Community
Build ID: 4ac9032163cf55c160145373e7c41741c9c339ca
CPU threads: 8; OS: Mac OS X 10.16; UI render: Skia/Raster; VCL: osx
Locale: nl-NL (nl_NL.UTF-8); UI: en-US
Calc: threaded
Comment 9 steve 2021-12-01 22:42:40 UTC
Haha, now I ran into a crash while trying to find Skia Raster 😂

I assume this is the same crash since as you correctly state it is related to having some dialog open.

Crash log (1 year): https://bin.disroot.org/?c61ed6e4f58e2301#Bc7jqwpvTJKUUtV76StxSNMLjXyDWkqzNtLbMBjXDN8B

Setting to NEW since I at least once reproduced the crash in question. Could you double check if you note anything from the crash log that matches / confirms it is the "correct" crash we are looking for.

Took another look at Preferences > View > and there is no info about Skia Raster (also LO just instantly crashed as soon as I opened the preferences window).

I have two Skia settings:
Use Skia for all rendering
    Force Skia software rendering

That's it. No raster anywhere in sight.
Comment 10 Telesto 2021-12-02 11:02:18 UTC
(In reply to steve from comment #9)
> Haha, now I ran into a crash while trying to find Skia Raster 😂

Well Skia Raster = Force software rendering; the about screen will show "Skia Raster" if Force software rendering being abled

I personally find this confusing too, but and complained; see bug 144330 (rejected)
Comment 11 Luboš Luňák 2021-12-08 16:41:25 UTC
I still cannot reproduce this using any of the ways described :(.
Comment 12 Telesto 2021-12-08 18:47:28 UTC
(In reply to Luboš Luňák from comment #11)
> I still cannot reproduce this using any of the ways described :(.

Only for my informaton: You're testing on own build or against the pre-published? [Not sure if the build bot is running some different version of Xcode or something like that] 
And which macOS version?
Comment 13 Telesto 2021-12-12 08:25:13 UTC
FWIW. I wanted to setup lode for a build with symbols for the crash, but lode is refusing to install
 lode % ./setup
Unknown Darwin kernel version 21.1.0 (macOS Moneterey)

Few side notes
A)Baseline starting to be ambitious to formally support. 
B)It might be that  the difference between build and runtime environment also starting to cause issues; no clue.
Comment 14 Luboš Luňák 2021-12-14 20:37:46 UTC
(In reply to Telesto from comment #12)
> Only for my informaton: You're testing on own build or against the
> pre-published? [Not sure if the build bot is running some different version
> of Xcode or something like that] 
> And which macOS version?

My own developer build on Mac Mini M1:
Version: 7.4.0.0.alpha0+ / LibreOffice Community
Build ID: 7e5af164b7d293dd410710bed411e1ca64bbecf7
CPU threads: 8; OS: Mac OS X 11.5.1; UI render: Skia/Metal; VCL: osx
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded
Comment 15 Telesto 2021-12-14 20:56:44 UTC
(In reply to Luboš Luňák from comment #14)
> (In reply to Telesto from comment #12)
> > Only for my informaton: You're testing on own build or against the
> > pre-published? [Not sure if the build bot is running some different version
> > of Xcode or something like that] 
> > And which macOS version?
> 
> My own developer build on Mac Mini M1:
> Version: 7.4.0.0.alpha0+ / LibreOffice Community
> Build ID: 7e5af164b7d293dd410710bed411e1ca64bbecf7
> CPU threads: 8; OS: Mac OS X 11.5.1; UI render: Skia/Metal; VCL: osx
> Locale: en-US (en_US.UTF-8); UI: en-US
> Calc: threaded

Double checking, as comment 0 isn't mentioning Skia Raster as explicit requirement (it is) and the about here showing Vulkan..
Comment 16 Telesto 2022-01-24 10:24:22 UTC
Finally got LODE setup. My custom build is running fine.  So this or a problem with code signing (I think it's not). Or something with the baseline version used to build LibreOffice.

Will try a more recent Master build soon, to check if it's still present..
Comment 17 Mike Saunders 2022-01-28 16:26:31 UTC
I'm using the TDF Apple Silicon (aarch64) build:

Version: 7.3.0.2 / LibreOffice Community
Build ID: f1c9017ac60ecca268da7b1cf147b10e244b9b21
CPU threads: 8; OS: Mac OS X 11.5.2; UI render: Skia/Metal; VCL: osx
Locale: en-GB (en_GB.UTF-8); UI: en-US
Calc: threaded

I can't reproduce the original crash described by Telesto, or the crash steps in comment 8. All seems to be working fine here... Anything else I can test?
Comment 18 Mike Saunders 2022-01-28 16:27:06 UTC
(In reply to Mike Saunders from comment #17)
> I'm using the TDF Apple Silicon (aarch64) build:
> 
> Version: 7.3.0.2 / LibreOffice Community
> Build ID: f1c9017ac60ecca268da7b1cf147b10e244b9b21
> CPU threads: 8; OS: Mac OS X 11.5.2; UI render: Skia/Metal; VCL: osx
> Locale: en-GB (en_GB.UTF-8); UI: en-US
> Calc: threaded
> 
> I can't reproduce the original crash described by Telesto, or the crash
> steps in comment 8. All seems to be working fine here... Anything else I can
> test?

Oh and I ran the graphics test and:

Graphics Backend used: skia
Passed Tests : 14
Quirky Tests : 66
Failed Tests : 24
Skipped Tests : 5
Comment 19 Telesto 2022-01-28 19:08:04 UTC
(In reply to Mike Saunders from comment #17)
> I'm using the TDF Apple Silicon (aarch64) build:
> 
> Version: 7.3.0.2 / LibreOffice Community
> Build ID: f1c9017ac60ecca268da7b1cf147b10e244b9b21
> CPU threads: 8; OS: Mac OS X 11.5.2; UI render: Skia/Metal; VCL: osx
> Locale: en-GB (en_GB.UTF-8); UI: en-US
> Calc: threaded
> 
> I can't reproduce the original crash described by Telesto, or the crash
> steps in comment 8. All seems to be working fine here... Anything else I can
> test?

A) The problem appears to be limited to macOS Monterey (all reports pointing into that direction)

B) It only occurs with Skia Raster mode (aka Software rendering). Tools  -> Options -> View -> Force Skia Software rendering. 

C) It only occurs with Master builds (not self-build)

D) It might be dependent on Haswell processor
Comment 20 Telesto 2022-01-28 21:16:21 UTC
Created attachment 177885 [details]
BT with symbols

Version: 7.4.0.0.alpha0+ / LibreOffice Community
Build ID: c1205c1cf6e08d94e6e2e2753679d99bc1842ca0
CPU threads: 8; OS: Mac OS X 12.0.1; UI render: Skia/Raster; VCL: osx
Locale: nl-NL (nl_NL.UTF-8); UI: en-US
Calc: threaded

OK it does happen with my own build
Comment 21 Telesto 2022-02-17 18:58:00 UTC
*** Bug 147302 has been marked as a duplicate of this bug. ***
Comment 22 Telesto 2022-02-21 13:15:02 UTC
*** Bug 147563 has been marked as a duplicate of this bug. ***
Comment 23 Buovjaga 2022-02-24 13:59:59 UTC
*** Bug 147638 has been marked as a duplicate of this bug. ***
Comment 24 Commit Notification 2022-06-17 04:17:00 UTC
Luboš Luňák committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/8a5beccc19b4fdffb7b82ba5fd26f4cf316d9811

handle GC* pixmap functions on Mac reading past pixmap (tdf#145843)

It will be available in 7.5.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 25 Commit Notification 2022-06-17 06:24:49 UTC
Luboš Luňák committed a patch related to this issue.
It has been pushed to "libreoffice-7-4":

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

handle GC* pixmap functions on Mac reading past pixmap (tdf#145843)

It will be available in 7.4.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.
Comment 26 Telesto 2022-07-03 01:56:43 UTC
Still crashing
Version: 7.5.0.0.alpha0+ / LibreOffice Community
Build ID: 7a89eae97a970939174d59aa58147eaa194acaee
CPU threads: 8; OS: Mac OS X 12.3.1; UI render: Skia/Raster; VCL: osx
Locale: nl-NL (nl_NL.UTF-8); UI: en-US
Calc: threaded
Comment 27 Telesto 2022-07-03 01:59:49 UTC
Created attachment 181096 [details]
Original patch

Note the commit is different to the patch I received by e-mail..
Comment 28 Telesto 2022-12-13 21:04:28 UTC
@Patrick Luby
Thanks for all the patches in the macOS area. I'm bit opportunistic here.. this bug is still bothering me. LibreOffice crashes regularly with Skia Raster enabled (no issue with Vulkan)

Version: 7.5.0.0.alpha1+ (X86_64) / LibreOffice Community
Build ID: da3dd48eaf9086f8ab28d6a6655f9a638e51433a
CPU threads: 8; OS: Mac OS X 12.3.1; UI render: Skia/Raster; VCL: osx
Locale: nl-NL (nl_NL.UTF-8); UI: en-US
Calc: threaded
Comment 29 Patrick Luby (volunteer) 2022-12-13 22:58:08 UTC
(In reply to Telesto from comment #28)
> @Patrick Luby
> Thanks for all the patches in the macOS area. I'm bit opportunistic here..
> this bug is still bothering me. LibreOffice crashes regularly with Skia
> Raster enabled (no issue with Vulkan)
> 
> Version: 7.5.0.0.alpha1+ (X86_64) / LibreOffice Community
> Build ID: da3dd48eaf9086f8ab28d6a6655f9a638e51433a
> CPU threads: 8; OS: Mac OS X 12.3.1; UI render: Skia/Raster; VCL: osx
> Locale: nl-NL (nl_NL.UTF-8); UI: en-US
> Calc: threaded

I was able to reproduce this bug with Skia/Raster. Unfortunately I was only able to reproduce one time. That was on my macOS Intel running macOS Monterey 12.6.2.

I am testing by running a local build (checked out from master earlier today) in lldb. Does anyone have any other steps that they use to trigger this crash?
Comment 30 Telesto 2022-12-14 04:25:31 UTC
(In reply to Patrick Luby from comment #29)
> I was able to reproduce this bug with Skia/Raster. Unfortunately I was only
> able to reproduce one time. That was on my macOS Intel running macOS
> Monterey 12.6.2.
> 
> I am testing by running a local build (checked out from master earlier
> today) in lldb. Does anyone have any other steps that they use to trigger
> this crash?

Whole problem, I can create the issue with a few steps.. somehow, but not everybody else does. 

Comment 8 works pretty reliable for me

Alternative
1. Open Impress from Start Center
2. Double click BeeHive template
3. LibreOffice -> About Window -> Press Copy About
4. Close the dialog
5. Enter Click to add title
6. CMD+V
7. LibreOffice -> About Window -> Press Copy about -> Might crash here
8. Close the dialog
9. Go to slide 2
10. CMD+V
11. LibreOffice -> About Window -> Press Copy about -> Crash

Alternative -> even less predictable
1. Open Writer from Start Center
2. LibreOffice -> Preferences -> View
3. Uncheck Use Skia for all rendering
4. Hoover over the Apply/ OK buttons.. Press Apply button. Close the restart button. Press Cancel in the Preference dialog 

It appears Window related, the dialogs appear like tip of the day/ template manager/ about window/ preference the often it happens.

But will there some kind of timing element.. 

Sidenote: the patch attachment 181096 [details] authored by Luboš Luňák - received by email - solves the issue. However a different patch got pushed at comment 24 for unknown reasons
Comment 31 Telesto 2022-12-14 04:38:39 UTC
Created attachment 184138 [details]
Debug patch

attachment 181096 [details] is based on output of debug code, attached. Output at that point in time (7 februari 2022)

> debug:12486:654528: XXX:0x600003e8e700
> 841x570*2R::1682x1140::2::289x143@(550,427) 1100,854,578,286::6728::6 2::6
> 2
>
> 2022-02-07 17:21:50.812613+0100 soffice[12486:654528]
> [org.libreoffice.script] copy_read_only: vm_copy failed: status 1.
Comment 32 Patrick Luby (volunteer) 2022-12-14 14:17:02 UTC
(In reply to Telesto from comment #30)
> 
> Whole problem, I can create the issue with a few steps.. somehow, but not
> everybody else does. 
> 
> Comment 8 works pretty reliable for me
> 
> Alternative
> 1. Open Impress from Start Center
> 2. Double click BeeHive template
> 3. LibreOffice -> About Window -> Press Copy About
> 4. Close the dialog
> 5. Enter Click to add title
> 6. CMD+V
> 7. LibreOffice -> About Window -> Press Copy about -> Might crash here
> 8. Close the dialog
> 9. Go to slide 2
> 10. CMD+V
> 11. LibreOffice -> About Window -> Press Copy about -> Crash
> 
> Alternative -> even less predictable
> 1. Open Writer from Start Center
> 2. LibreOffice -> Preferences -> View
> 3. Uncheck Use Skia for all rendering
> 4. Hoover over the Apply/ OK buttons.. Press Apply button. Close the restart
> button. Press Cancel in the Preference dialog 
> 
> It appears Window related, the dialogs appear like tip of the day/ template
> manager/ about window/ preference the often it happens.
> 
> But will there some kind of timing element.. 
> 
> Sidenote: the patch attachment 181096 [details] authored by Luboš Luňák -
> received by email - solves the issue. However a different patch got pushed
> at comment 24 for unknown reasons

Thank you for the steps. I can now reproduce the crash using your first alternative.

I now understand why the patch in attachment 181096 [details] was not used: it makes a copy of the bitmap in memory. It fixes the crashing, but it would require a lot more memory and frequently copying of bitmaps.

I added the debug patch in attachment 184138 [details] and I noticed the following debug output immediately before the crash:

debug:2178:56744: XXX:0x600003e71e00 709x464*2R::1418x928::2::244x232@(399,156) 798,312,488,464::5672::6 2::6 2
debug:2178:56744: XXX:0x600003e71e00 709x464*2R::1418x928::2::200x145@(509,319) 1018,638,400,290::5672::6 2::6 22022-12-14 08:57:10.358900-0500 soffice[2178:56744] [org.libreoffice.script] copy_read_only: vm_copy failed: status 1.

Note that the first line doesn't crash and the second one crashes. Both are taking a small subarea of the same bitmap. The difference is that the subarea in the second one aligns with the bottom, right edges of the bitmap.

From the above, I think that Luboš Luňák's "HACK for tdf#145843" in vcl/skia/osx/gdiimpl.cxx now makes sense to me. His fix is just missing cases like this.

I will see if I am able to expand his fix to handle this case.
Comment 33 Patrick Luby (volunteer) 2022-12-14 18:17:04 UTC Comment hidden (noise)
Comment 34 Patrick Luby (volunteer) 2022-12-14 18:44:25 UTC
(In reply to Patrick Luby from comment #33)
> I have posted the following patch that fixes this bug for on my macOS 12.6.2
> Intel machine:
> 
> https://gerrit.libreoffice.org/c/core/+/144194
> 
> @Telesto,
> 
> Does the patch fix the bug for you? If no, I have another fix that I can try
> to work around the "read past the end of the bitmap buffer" bug that Luboš
> Luňák's found in CGBitmapContextCreate().

Ignore the above patch. CGBitmapContextCreateWithData() crashes as well just not as frequently as CGBitmapContextCreate().
Comment 35 Patrick Luby (volunteer) 2022-12-14 23:03:06 UTC
I have uploaded "Patchset 3" to the following link:

https://bugs.documentfoundation.org/show_bug.cgi?id=145843

@Telesto

Patchset 3 fixes the crash when running Skia/Raster on my macOS 12.6.2 Intel laptop. Does Patchset 3 fix the crash on your machine?
Comment 36 Commit Notification 2022-12-15 05:34:32 UTC
Patrick Luby committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/9ec57a3dc7925d6f86a19d0e179e065df53e542f

tdf#145843 Do not use CGBitmapContextCreate() to create a bitmap context

It will be available in 7.6.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 37 Telesto 2022-12-15 12:42:51 UTC
(In reply to Patrick Luby from comment #35)
> I have uploaded "Patchset 3" to the following link:
> 
> https://bugs.documentfoundation.org/show_bug.cgi?id=145843
> 
> @Telesto
> 
> Patchset 3 fixes the crash when running Skia/Raster on my macOS 12.6.2 Intel
> laptop. Does Patchset 3 fix the crash on your machine?

Working like a charm
Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 102846d45cb9660805e209b6954c7b8d707b8288
CPU threads: 8; OS: Mac OS X 12.3.1; UI render: Skia/Raster; VCL: osx
Locale: nl-NL (nl_NL.UTF-8); UI: en-US
Calc: threaded
Comment 38 Commit Notification 2022-12-19 08:42:34 UTC
Patrick Luby committed a patch related to this issue.
It has been pushed to "libreoffice-7-5":

https://git.libreoffice.org/core/commit/1f58b2e0d941cfb8be10a5068b41096a06b078a6

tdf#145843 Do not use CGBitmapContextCreate() to create a bitmap context

It will be available in 7.5.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.
Comment 39 steve 2022-12-19 11:28:56 UTC
Verified as per https://bugs.documentfoundation.org/show_bug.cgi?id=145843#c37

Thanks Patrick for the fix.