Beep6581 / RawTherapee

A powerful cross-platform raw photo processing program
https://rawtherapee.com
GNU General Public License v3.0
2.77k stars 313 forks source link

Assertion '__n < this->size()' failed. #7085

Closed xiota closed 3 months ago

xiota commented 3 months ago

Short description Using a recent checkout (c74bcad19), an error message is shown when trying to load an image or start in a folder containing a pp3 file:

/usr/include/c++/14.1.1/array:208: std::array<_Tp, _Nm>::value_type& std::array<_Tp, _Nm>::operator[](size_type) [with _Tp = bool; long unsigned int _Nm = 5; reference = bool&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.
Aborted (core dumped)

Same error when building with either gcc 14.1.1+r58+gfc9fb69ad62 or clang 17.0.6. Both installed from official Arch repos. Disabling LTO doesn't make a difference.

git bisect:

Steps to reproduce

  1. Build latest commit. For convenience, I used aur/rawtherapee-git.
  2. Attempt to load an image (png, raf). Or start in a folder containing a pp3 file.

Expected behavior Image should load

Additional information

cat /usr/share/doc/rawtherapee/AboutThisBuild.txt ``` Version: 5.10-212-gc74bcad19 Branch: dev Commit: c74bcad19 Commit date: 2024-05-24 Compiler: cc 14.1.1 Processor: x86_64 System: Linux Bit depth: 64 bits Gtkmm: V3.24.9 Lensfun: V0.3.4.0 Build type: None Build flags: -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wp,-D_GLIBCXX_ASSERTIONS -flto=auto -std=c++11 -ffp-contract=off -Werror=unused-label -Werror=delete-incomplete -fno-math-errno -Wno-attributes -Wall -Wuninitialized -Wcast-qual -Wno-deprecated-declarations -Wno-unused-result -Wunused-macros -fopenmp -Werror=unknown-pragmas -ftree-vectorize Link flags: -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs -flto=auto OpenMP support: ON MMAP support: ON Build OS: Linux 6.6.31 x86_64 Build date: Sun, 26 May 2024 12:05:19 +0000 UTC Build epoch: 1716725119 Build UUID: 0080e441-3382-42c7-8a03-7e6bb655edd3 ```
gdb backtrace ``` /usr/include/c++/14.1.1/array:208: std::array<_Tp, _Nm>::value_type& std::array<_Tp, _Nm>::operator[](size_type) [with _Tp = bool; long unsigned int _Nm = 5; reference = bool&; size_type = long unsigned int]: Assertion '__n < this->size()' failed. Thread 11 "pool-rawtherape" received signal SIGABRT, Aborted. [Switching to Thread 0x7fffe70006c0 (LWP 211525)] 0x00007ffff58a8e44 in ?? () from /usr/lib/libc.so.6 (gdb) bt #0 0x00007ffff58a8e44 in ??? () at /usr/lib/libc.so.6 #1 0x00007ffff5850a30 in raise () at /usr/lib/libc.so.6 #2 0x00007ffff58384c3 in abort () at /usr/lib/libc.so.6 #3 0x00007ffff5ad2d60 in std::__glibcxx_assert_fail (file=, line=, function=, condition=) at /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/assert_fail.cc:41 #4 0x0000555556152ca8 in std::array::operator[] (this=, __n=) at /usr/include/c++/14.1.1/array:206 #5 std::array::operator[] (this=, __n=) at /usr/include/c++/14.1.1/array:206 #6 rtengine::procparams::ProcParams::load (this=, this@entry=0x7fffac003730, fname=, pedited=, pedited@entry=0x0) at /usr/src/debug/rawtherapee-git/RawTherapee/rtengine/procparams.cc:8857 #7 0x0000555555dd6f9a in Thumbnail::loadProcParams (this=0x7fffac003490) at /usr/include/glibmm-2.4/glibmm/ustring.h:1948 #8 0x0000555555de1e2d in Thumbnail::Thumbnail (this=this@entry=0x7fffac003490, cm=cm@entry=0x55555661ffc0 , fname=..., cf=cf@entry=0x7fffe6fff720) at /usr/src/debug/rawtherapee-git/RawTherapee/rtgui/thumbnail.cc:169 #9 0x00005555558c08c1 in CacheManager::getEntry (this=0x55555661ffc0 , fname=...) at /usr/src/debug/rawtherapee-git/RawTherapee/rtgui/cachemanager.cc:118 #10 0x0000555555d412fa in PreviewLoader::Impl::processNextJob (this=0x55555ccdc410) at /usr/src/debug/rawtherapee-git/RawTherapee/rtgui/previewloader.cc:131 #11 0x00007ffff7354f42 in ??? () at /usr/lib/libglibmm-2.4.so.1 #12 0x00007ffff74111f3 in ??? () at /usr/lib/libglib-2.0.so.0 #13 0x00007ffff740b236 in ??? () at /usr/lib/libglib-2.0.so.0 #14 0x00007ffff58a6ded in ??? () at /usr/lib/libc.so.6 #15 0x00007ffff592a0dc in ??? () at /usr/lib/libc.so.6 ```
Lawrence37 commented 3 months ago

It's an out of bounds access.

https://github.com/Beep6581/RawTherapee/blob/c74bcad19e99cca59e892ff844df2ccc24048d25/rtengine/procparams.cc#L8857C17-L8857C146

Commit 3845b720a28817100bd69c40fd815933d8e6b72c increased the size of tone equalizer bands, but the corresponding pedited array is still the same size.

Desmis commented 3 months ago

@Lawrence37 @xiota This was an oversight on my part a few months ago... What do we do ? Is it a simple commit?

struct ToneEqualizerParamsEdited { bool enabled; std::array<bool, 5> bands; ==> change to ==> std::array<bool, 6> bands; bool regularization; bool show_colormap; bool pivot; };

Jacques

Lawrence37 commented 3 months ago

Yes, that should be the solution.

Desmis commented 3 months ago

I push the change to dev, now

Jacques

Desmis commented 3 months ago

Done Jacques

xiota commented 3 months ago

@Lawrence37 @Desmis Thank you for working on this issue. I have confirmed that 4a5194e2d7df3e4ddc9acae19867eb46ee0c5130 fixes this issue.