wesnoth 1.17 crashes in Credits
Game and System Information
The Battle for Wesnoth version 1.17.6+dev (54fedb4d6a8-Clean) x86_64 Running on Fedora Linux 36 (Workstation Edition) x86_64 Distribution channel: Default
reproduced also on latest nightly flatpak
Description of the bug
20220807 16:03:21 error draw/manager: Attempted to invalidate region [0,0|1920,1017] during draw
terminate called after throwing an instance of 'game::error'
what(): invalidate during draw
Aborted (core dumped)
#0 __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0)
at pthread_kill.c:44
#1 0x00007f0504e3ccb3 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2 0x00007f0504dec9c6 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3 0x00007f0504dd67f4 in __GI_abort () at abort.c:79
#4 0x00007f0505152b57 in __gnu_cxx::__verbose_terminate_handler() ()
at ../../../../libstdc++-v3/libsupc++/vterminate.cc:95
#5 0x00007f050515e43c in __cxxabiv1::__terminate(void (*)()) (handler=<optimized out>)
at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:48
#6 0x00007f050515d4a9 in __cxa_call_terminate(_Unwind_Exception*) (ue_header=0x56248b7f9a50)
at ../../../../libstdc++-v3/libsupc++/eh_call.cc:54
#7 0x00007f050515dbc6 in __cxxabiv1::__gxx_personality_v0(int, _Unwind_Action, _Unwind_Exception_Class, _Unwind_Exception*, _Unwind_Context*)
(version=<optimized out>, actions=6, exception_class=5138137972254386944, ue_header=<optimized out>, context=0x7ffe883850c0) at ../../../../libstdc++-v3/libsupc++/eh_personality.cc:688
#8 0x00007f0504fc6c74 in _Unwind_RaiseException_Phase2
(exc=0x56248b7f9a50, context=0x7ffe883850c0, frames_p=0x7ffe883851b0) at ../../../libgcc/unwind.inc:64
#9 0x00007f0504fc7331 in _Unwind_RaiseException (exc=0x56248b7f9a50) at ../../../libgcc/unwind.inc:136
#10 0x00007f050515e6fb in __cxxabiv1::__cxa_throw(void*, std::type_info*, void (*)(void*))
(obj=<optimized out>, tinfo=0x562483f676b0 <typeinfo for game::error>, dest=0x562482e2a8f0 <game::error::~error()>) at ../../../../libstdc++-v3/libsupc++/eh_throw.cc:93
#11 0x0000562482cc2b58 in draw_manager::invalidate_region(rect const&) [clone .cold] ()
#12 0x000056248316a196 in gui2::widget::queue_redraw() ()
#13 0x0000562482ee40db in gui2::window::~window() ()
#14 0x0000562482ef62ce in void gui2::dialogs::end_credits::display<>() ()
#15 0x0000562482d7eb14 in main ()
Steps to reproduce the behavior
- Click 'Credits'
Expected behavior
No response
Additional context
No response
The backtrace is spurious but this does crash. 5129d61dd2f46c86854f81fe2badc893c523673c should fix the misleading backtrace.
Related: #6845
I compiled wesnoth with https://github.com/wesnoth/wesnoth/commit/5129d61dd2f46c86854f81fe2badc893c523673c, now game exits with err code 1 and following message:
20220809 19:43:31 warning draw/manager: exception thrown during expose 0x7ffecdc54d50
Caught general 'St12length_error' exception:
Text is too long to render
Retitled to separate this from #6845, which has been reported in 1.16.x. In 1.16, src/gui/core/canvas.cpp's text_shape::draw clips the rendering to the visible screen area. In 1.17, the issue is that 2931615cdfbb12c6c0b04f1923807df1165806ff has removed that clipping, and IIUC @Vultraz is going to add a redesigned text-cache instead.
I confirm on 1.17.7+dev (314f6f7c78d), same error message as what grz0 quoted.
Still confirmed on 1.17.9+dev
20221110 17:20:10 warning draw/manager: exception std::length_error thrown during expose 0x11493fdec0
Caught general 'St12length_error' exception:
Text is too long to render
Yes, it's still there. As steve mentioned, the commit that caused the crash (even says so in the commit message) is 2931615cdfbb12c6c0b04f1923807df1165806ff.
Reverting just the src/gui/core/canvas.cpp changes from 2931615 doesn't work. It stops the crash, but only renders the first few lines (so most of the scrolling area is blank).
Vultraz said that he would fix this. It was impossible to cleanly separate out the breaking changes in it from everything else. It's caused by his changes to rendered text caching that render and cache the whole text blob in stead of rerendering the currently viewable portion every scroll tick. Credits are too long to render all at once, as it would create too tall a rendering surface. I believe cairo is throwing an exception when asked to do so.
I tried to reapply f282eb7948's method to the current canvas.cpp, and found that draw::fill and draw::blit behave oddly in the credits screen's scroll_label. Although the width of rectangles passed to them is used (as a drawing-space width), the height appears to be also scaled by the amount needed for the whole scroll_label to fit on screen. If there's enough text to fill 5 screen-height pages of text, then the height is effectively divided by 5.
The commit that's auto-linked today (efa1fa9) demonstrates this.
That PR wasn't supposed to close this.