Opened 4 months ago

Closed 4 months ago

#15243 closed defect (fixed)

Segfault switching to OpenGL

Reported by: scummvmuser Owned by: bluegr
Priority: high Component: GUI
Version: Keywords:
Cc: Game:

Description

In Global Options, my graphics mode is set to "SDL Surface". If I set that to "OpenGL" and click Apply or OK, ScummVM segfaults. (I guess _aspectCheckbox is nil when it should be something.)

Debian 12.6 amd64 with nvidia-driver 535.183.01-1~deb12u1
ScummVM 2.9.0git5811-gc5948672ff2 (Jul  2 2024 22:04:47)
Using SDL backend with SDL 2.26.5
Features compiled in: Vorbis SEQ TiMidity RGB FreeType2 PNG SDL2 TinyGL OpenGL
$ git checkout c3c9f43a047 # AGS: Fix build when SIZE_MAX is 64-bit sized
$ git bisect good
4875573f66ebb474cab3bd36600703a242cbb1ff is the first bad commit

    GUI: Disable shader controls instead of hiding them. Prvides better UX

 gui/options.cpp | 80 ++++++++++++++++++++++++---------------------------------
 gui/options.h   |  3 +++
 2 files changed, 37 insertions(+), 46 deletions(-)
AddressSanitizer:DEADLYSIGNAL
=================================================================
==15550==ERROR: AddressSanitizer: SEGV on unknown address 0x0000000000f8 (pc 0x55d156544fd8 bp 0x7ffd4b20d6a0 sp 0x7ffd4b20d690 T0)
==15550==The signal is caused by a READ memory access.
==15550==Hint: address points to the zero page.
    #0 0x55d156544fd8 in GUI::Widget::setEnabled(bool) (/home/user/scummvm/scummvm+0x6a7fd8)
    #1 0x55d1564970dd in GUI::OptionsDialog::setGraphicSettingsState(bool) (/home/user/scummvm/scummvm+0x5fa0dd)
    #2 0x55d1564b095a in GUI::OptionsDialog::setupGraphicsTab() (/home/user/scummvm/scummvm+0x61395a)
    #3 0x55d156495ea5 in GUI::OptionsDialog::handleCommand(GUI::CommandSender*, unsigned int, unsigned int) (/home/user/scummvm/scummvm+0x5f8ea5)
    #4 0x55d1564c783b in GUI::GlobalOptionsDialog::handleCommand(GUI::CommandSender*, unsigned int, unsigned int) (/home/user/scummvm/scummvm+0x62a83b)
    #5 0x55d156441aad in GUI::CommandSender::sendCommand(unsigned int, unsigned int) (/home/user/scummvm/scummvm+0x5a4aad)
    #6 0x55d15659b79e in GUI::ScrollContainerWidget::reflowLayout() (/home/user/scummvm/scummvm+0x6fe79e)
    #7 0x55d1565a04de in GUI::TabWidget::reflowLayout() (/home/user/scummvm/scummvm+0x7034de)
    #8 0x55d156433337 in GUI::Dialog::reflowLayout() (/home/user/scummvm/scummvm+0x596337)
    #9 0x55d1564b0569 in GUI::OptionsDialog::reflowLayout() (/home/user/scummvm/scummvm+0x613569)
    #10 0x55d1564c8dcb in GUI::GlobalOptionsDialog::reflowLayout() (/home/user/scummvm/scummvm+0x62bdcb)
    #11 0x55d15643ec03 in GUI::GuiManager::screenChange() (/home/user/scummvm/scummvm+0x5a1c03)
    #12 0x55d15643ea47 in GUI::GuiManager::checkScreenChange() (/home/user/scummvm/scummvm+0x5a1a47)
    #13 0x55d15648f53f in GUI::OptionsDialog::apply() (/home/user/scummvm/scummvm+0x5f253f)
    #14 0x55d1564c376d in GUI::GlobalOptionsDialog::apply() (/home/user/scummvm/scummvm+0x62676d)
    #15 0x55d156494dde in GUI::OptionsDialog::close() (/home/user/scummvm/scummvm+0x5f7dde)
    #16 0x55d1564c567b in GUI::GlobalOptionsDialog::close() (/home/user/scummvm/scummvm+0x62867b)
    #17 0x55d156496384 in GUI::OptionsDialog::handleCommand(GUI::CommandSender*, unsigned int, unsigned int) (/home/user/scummvm/scummvm+0x5f9384)
    #18 0x55d1564c783b in GUI::GlobalOptionsDialog::handleCommand(GUI::CommandSender*, unsigned int, unsigned int) (/home/user/scummvm/scummvm+0x62a83b)
    #19 0x55d156441aad in GUI::CommandSender::sendCommand(unsigned int, unsigned int) (/home/user/scummvm/scummvm+0x5a4aad)
    #20 0x55d1565477eb in GUI::ButtonWidget::handleMouseUp(int, int, int, int) (/home/user/scummvm/scummvm+0x6aa7eb)
    #21 0x55d156434161 in GUI::Dialog::handleMouseUp(int, int, int, int) (/home/user/scummvm/scummvm+0x597161)
    #22 0x55d15643fdbb in GUI::GuiManager::processEvent(Common::Event const&, GUI::Dialog*) (/home/user/scummvm/scummvm+0x5a2dbb)
    #23 0x55d15643c7fa in GUI::GuiManager::runLoop() (/home/user/scummvm/scummvm+0x59f7fa)
    #24 0x55d156432fc0 in GUI::Dialog::runModal() (/home/user/scummvm/scummvm+0x595fc0)
    #25 0x55d15644e997 in GUI::LauncherDialog::handleCommand(GUI::CommandSender*, unsigned int, unsigned int) (/home/user/scummvm/scummvm+0x5b1997)
    #26 0x55d156458ead in GUI::LauncherSimple::handleCommand(GUI::CommandSender*, unsigned int, unsigned int) (/home/user/scummvm/scummvm+0x5bbead)
    #27 0x55d156441aad in GUI::CommandSender::sendCommand(unsigned int, unsigned int) (/home/user/scummvm/scummvm+0x5a4aad)
    #28 0x55d1565477eb in GUI::ButtonWidget::handleMouseUp(int, int, int, int) (/home/user/scummvm/scummvm+0x6aa7eb)
    #29 0x55d156434161 in GUI::Dialog::handleMouseUp(int, int, int, int) (/home/user/scummvm/scummvm+0x597161)
    #30 0x55d15643fdbb in GUI::GuiManager::processEvent(Common::Event const&, GUI::Dialog*) (/home/user/scummvm/scummvm+0x5a2dbb)
    #31 0x55d15643c7fa in GUI::GuiManager::runLoop() (/home/user/scummvm/scummvm+0x59f7fa)
    #32 0x55d1564497b0 in GUI::LauncherDialog::run() (/home/user/scummvm/scummvm+0x5ac7b0)
    #33 0x55d1564529d5 in GUI::LauncherChooser::runModal() (/home/user/scummvm/scummvm+0x5b59d5)
    #34 0x55d15615b02d in launcherDialog() (/home/user/scummvm/scummvm+0x2be02d)
    #35 0x55d156162d69 in scummvm_main (/home/user/scummvm/scummvm+0x2c5d69)
    #36 0x55d156156edf in main (/home/user/scummvm/scummvm+0x2b9edf)
    #37 0x7f142fa46249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #38 0x7f142fa46304 in __libc_start_main_impl ../csu/libc-start.c:360
    #39 0x55d156145240 in _start (/home/user/scummvm/scummvm+0x2a8240)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/home/user/scummvm/scummvm+0x6a7fd8) in GUI::Widget::setEnabled(bool)
==15550==ABORTING

Please let me know how I might provide more helpful info. Sorry if my bisect misleads; I don't really know what I'm doing.

As a workaround to set my graphics mode to OpenGL, I checked out the good commit mentioned above, adjusted the setting, then came back to present. (I should have checked docs for scummvm.ini and made the change there, though.)

Change History (2)

comment:1 by scummvmuser, 4 months ago

I found that if the Options box is opened while in SDL mode and --disable-aspect was given to configure, then the Aspect checkbox is not there, but it looks like in OpenGL mode it is expected regardless (and is present if the Options are opened while in OpenGL mode.)
I wonder whether that configure option should be made more properly effective, but in any case I mimicked nearby lines and did

diff --git a/gui/options.cpp b/gui/options.cpp
index 1ae2bd3edcd..d1c33f373d0 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -2033,6 +2033,8 @@ void OptionsDialog::setupGraphicsTab() {
                        rebuild();
                } else if (!_stretchPopUp && g_system->hasFeature(OSystem::kFeatureStretchMode)) {
                        rebuild();
+               } else if (!_aspectCheckbox && g_system->hasFeature(OSystem::kFeatureAspectRatioCorrection)) {
+                       rebuild();
                }
                setGraphicSettingsState(_enableGraphicSettings);
        }

and I no longer crash. I don't know if this is fixing the problem in the right place...

comment:2 by bluegr, 4 months ago

Owner: set to bluegr
Resolution: fixed
Status: newclosed

Thanks for finding and fixing this issue!

Note: See TracTickets for help on using tickets.