Bug 503682 - Asserts in OpenCV code (matrix.cpp:806) with 2 displays
Summary: Asserts in OpenCV code (matrix.cpp:806) with 2 displays
Status: REPORTED
Alias: None
Product: Spectacle
Classification: Applications
Component: General (other bugs)
Version First Reported In: 6.3.4
Platform: Arch Linux Linux
: NOR crash
Target Milestone: ---
Assignee: Noah Davis
URL:
Keywords: multiscreen
: 494067 504760 506202 (view as bug list)
Depends on:
Blocks:
 
Reported: 2025-05-02 20:13 UTC by Alex Rozkov
Modified: 2025-06-26 16:36 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Backtrace (92.28 KB, text/plain)
2025-05-02 20:13 UTC, Alex Rozkov
Details
Displays config (641.26 KB, image/png)
2025-05-02 20:13 UTC, Alex Rozkov
Details
Bactrace fragment with mainMat and rect variables (2.30 MB, image/png)
2025-05-08 20:40 UTC, Alex Rozkov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Rozkov 2025-05-02 20:13:09 UTC
Created attachment 180889 [details]
Backtrace

SUMMARY
Spectacle crashes on launch if second display is connected. All works fine with 1 display

STEPS TO REPRODUCE
1. Connect second display
2. Launch spectacle

OBSERVED RESULT

First 3 lines are printed always, even if all works fine:

kpipewire_vaapi_logging: VAAPI: Intel iHD driver for Intel(R) Gen Graphics - 25.2.1 () in use for device "/dev/dri/renderD128"
kpipewire_vaapi_logging: VAAPI: Fail to get RC attribute from the 14 6 of the device "/dev/dri/renderD128"
kpipewire_vaapi_logging: VAAPI: Fail to get RC attribute from the 14 8 of the device "/dev/dri/renderD128"
terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.11.0) /usr/src/debug/opencv/opencv/modules/core/src/matrix.cpp:806: error: (-215:Assertion failed) 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows in function 'Mat'

KCrash: Application 'spectacle' crashing... crashRecursionCounter = 2
[1]    2026 IOT instruction (core dumped)  spectacle


SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.3.4
KDE Frameworks Version: 6.13.0
Qt Version: 6.9.0
Kernel Version: 6.14.4-arch1-2 (64-bit)
Graphics Platform: Wayland
Processors: 22 × Intel® Core™ Ultra 7 155H
Memory: 30.8 GiB of RAM
Graphics Processor: NVIDIA RTX 500 Ada Generation Laptop GPU |OR (result is same)| Mesa Intel® Arc

ADDITIONAL INFORMATION
Backtrace in attachment
Displays configuration is attached too
Comment 1 Alex Rozkov 2025-05-02 20:13:34 UTC
Created attachment 180890 [details]
Displays config
Comment 2 Nate Graham 2025-05-06 16:08:10 UTC
Cannot reproduce with my dual-screen setup, but it's an assert not a crash, and it's in OpenCV (a dependency of Spectacle) rather than Spectacle itself.
Comment 3 Alex Rozkov 2025-05-08 20:40:46 UTC
Created attachment 181088 [details]
Bactrace fragment with mainMat and rect variables
Comment 4 Alex Rozkov 2025-05-08 20:41:04 UTC
(In reply to Nate Graham from comment #2)
> Cannot reproduce with my dual-screen setup, but it's an assert not a crash,
> and it's in OpenCV (a dependency of Spectacle) rather than Spectacle itself.

It's a spectacle bug in the following function:
https://invent.kde.org/graphics/spectacle/-/blob/master/src/Platforms/ImagePlatformKWin.cpp?ref_type=heads#L123

OpenCV assert checks parameters of mainMat and rect. Especially rect.x + rect.width <= mainMat.cols must be true, but it isn't (4431 + 6400 > 10830).
I attached screenshot of backtrace with this info
Comment 5 Bug Janitor Service 2025-05-09 22:09:58 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/spectacle/-/merge_requests/450
Comment 6 Alex Rozkov 2025-05-11 09:28:52 UTC
(In reply to Bug Janitor Service from comment #5)
> A possibly relevant merge request was started @
> https://invent.kde.org/graphics/spectacle/-/merge_requests/450

I built this MR and it fixes the problem. Thx
Comment 7 Noah Davis 2025-05-11 23:29:41 UTC
Git commit b437ca399a7a8df92fa8829b114732dc2ddf4b34 by Noah Davis.
Committed on 09/05/2025 at 22:09.
Pushed by ndavis into branch 'master'.

ImagePlatformKWin: Clip sub image ROI for combined image to prevent OpenCV assert crash

The possibility should be completely prevented now.

M  +10   -6    src/Platforms/ImagePlatformKWin.cpp

https://invent.kde.org/graphics/spectacle/-/commit/b437ca399a7a8df92fa8829b114732dc2ddf4b34
Comment 8 Noah Davis 2025-05-23 10:53:34 UTC
*** Bug 494067 has been marked as a duplicate of this bug. ***
Comment 9 Noah Davis 2025-05-26 11:37:53 UTC
*** Bug 504760 has been marked as a duplicate of this bug. ***
Comment 10 Nate Graham 2025-06-26 16:31:30 UTC
*** Bug 506202 has been marked as a duplicate of this bug. ***
Comment 11 Nate Graham 2025-06-26 16:32:05 UTC
Re-opening since Bug 506202 reports the same thing, but in the version (Plasma 6.4.0) that the intended fix went into.
Comment 12 Duncan 2025-06-26 16:36:39 UTC
(In reply to Nate Graham from comment #11)
> Re-opening since Bug 506202 reports the same thing, but in the version
> (Plasma 6.4.0) that the intended fix went into.

For clarity - twin monitors on that machine, and an i915 driven graphics card. The exact same release from Fedora on my desktop with an AMD 6700XT does not replicate the problem, connected to the same monitors.

I'll re-test the single display thing in the initial report by Alex tomorrow if that is of any help.

If there's any other data that would help, please let me know and I'll see if I can gather it.

Working machine:
Operating System: Fedora Linux 42
KDE Plasma Version: 6.4.0
KDE Frameworks Version: 6.15.0
Qt Version: 6.9.1
Kernel Version: 6.15.3-200.fc42.x86_64 (64-bit)
Graphics Platform: Wayland
Graphics Processor: AMD Radeon RX 6700 XT