CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.63k stars 4.18k forks source link

Cataclysm DDA segfaults if sound isn't available #52732

Open theodis opened 3 years ago

theodis commented 3 years ago

Describe the bug

The game immediately segfaults on launch if sound is unavailable even if sound is turned off in the game options.

Steps To Reproduce

For a Linux system using PulseAudio just run pulseaudio -k to kill the sound subsystem and try to launch the game

Expected behavior

If sound isn't available, then the game should play without sound.

Screenshots

No response

Versions and configuration

OS: Gentoo Game Version: 0.F-3781-g3df2f1de5e-dirty Graphics Version: Tiles

Additional context

ALSA lib /var/tmp/portage/media-plugins/alsa-plugins-1.2.5/work/alsa-plugins-1.2.5/pulse/pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

The program has crashed. See the log file for a stack trace. CRASH LOG FILE: /home/theodis/.cataclysm-dda/config/crash.log VERSION: 0.F-3781-g3df2f1de5e-dirty TYPE: Signal MESSAGE: SIGSEGV: Segmentation fault STACK TRACE:

cataclysm-tiles(debug_write_backtrace(std::ostream&)+0x3d) [0x55ac1079d0ed]
cataclysm-tiles(+0x8c513c) [0x55ac1077213c]
cataclysm-tiles(+0x8c55c8) [0x55ac107725c8]
/lib64/libc.so.6(+0x385a0) [0x7f51650505a0]
cataclysm-tiles(+0x1362289) [0x55ac1120f289]
cataclysm-tiles(cata_cursesport::curses_drawwindow(catacurses::window const&)+0xe8) [0x55ac112255f8]
cataclysm-tiles(+0x8f50a8) [0x55ac107a20a8]
cataclysm-tiles(ui_adaptor::redraw_invalidated()+0xfa) [0x55ac112aedca]
cataclysm-tiles(+0x8f62c8) [0x55ac107a32c8]
cataclysm-tiles(realDebugmsg(char const*, char const*, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)+0x186) [0x55ac107a4be6]
cataclysm-tiles(+0x5dc0a6) [0x55ac104890a6]
cataclysm-tiles(+0x28ffb6) [0x55ac1013cfb6]
cataclysm-tiles(JsonObject::finish()+0xc) [0x55ac10bf2eec]
cataclysm-tiles(DynamicDataLoader::load_all_from_json(JsonIn&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, loading_ui&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)+0x16d) [0x55ac109e705d]
cataclysm-tiles(DynamicDataLoader::load_data_from_path(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, loading_ui&)+0x30c) [0x55ac109e74cc]
cataclysm-tiles(load_soundset()+0x349) [0x55ac11220df9]
cataclysm-tiles(catacurses::init_interface()+0x16d7) [0x55ac11229a47]
cataclysm-tiles(main+0xff8) [0x55ac10241068]
/lib64/libc.so.6(__libc_start_main+0xcd) [0x7f516503b7fd]
cataclysm-tiles(_start+0x2a) [0x55ac104385aa]

Attempting to repeat stack trace using debug symbols…
debug_write_backtrace(std::ostream&)
??:?
dt_by_name(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
??:?
dt_by_name(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
??:?
??
??:0
projected_window_height()
??:?
cata_cursesport::curses_drawwindow(catacurses::window const&)
??:?
game_info::game_report[abi:cxx11]()
??:?
ui_adaptor::redraw_invalidated()
??:?
load_damage_instance(JsonArray const&)
??:?
realDebugmsg(char const*, char const*, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
??:?
reload_activity_actor::can_reload() const
??:?
??
??:0
JsonObject::finish()
??:?
DynamicDataLoader::load_all_from_json(JsonIn&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, loading_ui&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
??:?
DynamicDataLoader::load_data_from_path(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, loading_ui&)
??:?
load_soundset()
??:?
catacurses::init_interface()
??:?
main
??:?
??
??:0
_start
??:?

Aborted (core dumped)

theodis commented 3 years ago

Also, this was working as expected after building off master last week Friday, so I assume this was caused by some change made over the last few days.

wapcaplet commented 3 years ago

I was not able to reproduce this on my Linux box (PopOS/Ubuntu) with the same experimental version, but it appears my pulseaudio daemon automatically restarts whenever it is killed, so I can't seem to get in a situation where the daemon is shut down to test it.

theodis commented 3 years ago

Well another use case of mine where this is affected is that I have two accounts on my system a work account and a personal account. When I'm working and have a break I'll occasionally su into my personal account and run cataclysm, this'll run cataclysm with my personal configurations and saves but won't have access to the sound system, similar to if pulseaudio is killed.

So another way to test if you have multiple accounts on a linux system is to log into one, in a terminal use the su command to switch to the other account, and then launch cataclysm from the terminal.

hexagonrecursion commented 2 years ago

I could not reproduce this issue. The game launched fine.

  1. Kill pulseaudio and verify that it did not restart
    $ pgrep pulse
    798
    $ pulseaudio -k
    $ pgrep pulse
  2. Start cataclysm-tiles
  3. Play now!
  4. Everything works as intended

Quitting the game did result in a hang though:

  1. Exit to the main menu
  2. Press [Q] in the main menu
  3. The process hangs (see backtrace)
#0  0x00007ffff7de4a8a in __futex_abstimed_wait_common64 ()
   from /lib64/libpthread.so.0
#1  0x00007ffff7dd9793 in __pthread_clockjoin_ex () from /lib64/libpthread.so.0
#2  0x00007ffff7e161d6 in close_audio_device () from /lib64/libSDL2-2.0.so.0
#3  0x00007ffff7fa6c1f in Mix_CloseAudio () from /lib64/libSDL2_mixer-2.0.so.0
#4  0x00000000036c7934 in shutdown_sound () at src/sdlsound.cpp:146
#5  0x00000000036d6886 in WinDestroy () at src/sdltiles.cpp:450
#6  0x00000000036d6872 in catacurses::endwin () at src/sdltiles.cpp:3765
#7  0x0000000002f3e861 in (anonymous namespace)::exit_handler (s=s@entry=-999)
    at src/main.cpp:126
#8  0x0000000002f3dc50 in main (argc=<optimized out>, argv=<optimized out>)
    at src/main.cpp:714