Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime crash: When 'MUSIC TYPE' is set to 'JUKEBOX' a 'Segmentation fault' will occur when starting new levels. #672

Closed
BryanFRitt opened this issue Oct 18, 2022 · 9 comments
Assignees
Labels

Comments

@BryanFRitt
Copy link

BryanFRitt commented Oct 18, 2022

Linux, Debian Stable, Debian GNU/Linux 11 (bullseye)
D2X-Rebirth v0.61 0.60.0-beta2-2122-ge3faab0899bc Oct 3 2022 22:23:37
Compiled
Intel CPU, ...

Runtime crash: When 'MUSIC TYPE' is set to 'JUKEBOX' a 'Segmentation fault' will occur when starting new levels.
Note: I'm thinking this 'JUKEBOX' setting may cause some other random 'Segmentation fault's as well, but I'm not sure.

e.g. This 'Segmentation fault' will occur after escaping the first mine, when about to start the next mine, if 'MUSIC TYPE' is set to 'JUKEBOX'.

Set 'MUSIC TYPE' to anything other than 'JUKEBOX' and this 'segmentation fault' won't occur.

Terminal messages:

You have escaped the mine!
Segmentation fault

with -debug -verbose it crashes with this message, on starting level 2 after finishing level 1

Cannot load file text of binary version of <d2leva-1.txb>
Jukebox: 22 music file(s) found in
Segmentation fault

@vLKp
Copy link
Contributor

vLKp commented Oct 19, 2022

When reporting a crash with segmentation fault, please collect a backtrace. I cannot reproduce this crash here. As a guess, are you using Fluidsynth? There is a known issue with certain versions of Fluidsynth and SDL: issue #614.

@BryanFRitt
Copy link
Author

When reporting a crash with segmentation fault, please collect a backtrace.

I tried
gdb CommandToStart_dxx-rebirth
r
then try to recreate the error, but instead of just getting a 'Segmentation fault' when this error occurs, it freezes the whole GUI, and the best thing I can do something like a ctrl+alt+F1-6, shutdown now -r
Is there a good way to get a backtrace of this?

are you using Fluidsynth?

Looks like Fluidsynth version 2.1.7-1.1 is installed. Should I uninstall it and/or install something else?

see issue #614
notes: These were already installed.
sudo apt install libsdl2-image-dev libsdl2-mixer-dev
libsdl2-image-dev is already the newest version (2.0.5+dfsg1-2).
libsdl2-mixer-dev is already the newest version (2.0.4+dfsg1-3).

Since this appears to be a problem in an external library, closing without change to Rebirth.

If this is true and related as the same bug, I guess this is going to closed too.

@BryanFRitt
Copy link
Author

BryanFRitt commented Oct 19, 2022

Might be a different bug, but here's what I got from one of the random times dxx-rebirth crashes when 'JUKEBOX' option is set.

[xcb] Unknown sequence number while processing reply
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
d2x-rebirth: ../../src/xcb_io.c:725: _XReply: Assertion `!xcb_xlib_threads_sequence_lost' failed.
Aborted

@vLKp
Copy link
Contributor

vLKp commented Oct 19, 2022

Is there a good way to get a backtrace of this?

gdb can also be used on a core dump taken after the crash. Your immediate problem appears to be that you have Full Screen mode enabled which, if not configured otherwise, will grab the keyboard to allow you to use all possible keyboard keys for ship navigation. When the game crashes, the debugger pauses the game before the game exits, and the grab is not released until the game exits. You can start the game with -no-grab to inhibit all keyboard grabbing. This is awkward for regular keyboard-driven play, but extremely useful when using a debugger. I added that option specifically to deal with the combination of full screen and a debugger.

As I understand the Fluidsynth issue, SDL was misusing Fluidsynth, so you should either not use Fluidsynth at all, or use a version of SDL which does not misuse it. Are you using SDL1 or SDL2 with Rebirth? Last I heard, only SDL2 had received the fix.

If this is true and related as the same bug, I guess this is going to closed too.

If it is the same bug, then there is nothing I can do about it, because it is a problem in SDL. We do not know yet if it is the same bug.

but here's what I got from one of the random times dxx-rebirth crashes when 'JUKEBOX' option is set.

That might be a consequence of memory corruption. As I understand issue #614, memory corruption is one possible outcome of that bug.

@BryanFRitt
Copy link
Author

BryanFRitt commented Oct 20, 2022

played the game finishing level 1 in windowed mode with 'JUKEBOX' selected.
/usr/bin/gdb --args CommandToStart_d2x-rebirth -no-grab

(gdb) bt
#0  0x00007ffff755ae1a in  () at /usr/lib/x86_64-linux-gnu/libfluidsynth.so.2
#1  0x00007ffff755c35c in  () at /usr/lib/x86_64-linux-gnu/libfluidsynth.so.2
#2  0x00007ffff755cb21 in  () at /usr/lib/x86_64-linux-gnu/libfluidsynth.so.2
#3  0x00007ffff7572b2a in delete_fluid_synth () at /usr/lib/x86_64-linux-gnu/libfluidsynth.so.2
#4  0x00007ffff7ec031b in fluidsynth_freesong () at /usr/lib/x86_64-linux-gnu/libSDL_mixer-1.2.so.0
#5  0x00007ffff7eb3597 in Mix_FreeMusic () at /usr/lib/x86_64-linux-gnu/libSDL_mixer-1.2.so.0
#6  0x000055555565d88b in dcx::(anonymous namespace)::Music_delete::operator() (m=<optimized out>, this=0x555555eddaf8 <dcx::(anonymous namespace)::current_music>) at common/arch/sdl/digi_mixer_music.cpp:39
#7  std::__uniq_ptr_impl<_Mix_Music, dcx::(anonymous namespace)::Music_delete>::reset (__p=0x0, this=0x555555eddaf8 <dcx::(anonymous namespace)::current_music>) at /usr/include/c++/10/bits/unique_ptr.h:182
#8  std::unique_ptr<_Mix_Music, dcx::(anonymous namespace)::Music_delete>::reset (__p=0x0, this=0x555555eddaf8 <dcx::(anonymous namespace)::current_music>) at /usr/include/c++/10/bits/unique_ptr.h:456
#9  dcx::mix_free_music() () at common/arch/sdl/digi_mixer_music.cpp:221
#10 dcx::mix_play_file(char const*, int, void (*)()) (filename=filename@entry=0x5555563b7130 "briefing.mid", loop=0, entry_hook_finished_track=0x55555565e4f0 <dcx::jukebox_hook_next()>)
    at common/arch/sdl/digi_mixer_music.cpp:148
#11 0x00005555556243da in songs_play_file(char const*, int, void (*)()) (filename=filename@entry=0x5555563b7130 "briefing.mid", repeat=<optimized out>, hook_finished_track=<optimized out>)
    at similar/main/songs.cpp:475
#12 0x000055555565e454 in d2x::jukebox_play() () at similar/arch/sdl/jukebox.cpp:343
#13 0x0000555555624811 in d2x::songs_play_level_song(int, int) (levelnum=<optimized out>, offset=offset@entry=0) at similar/main/songs.cpp:732
#14 0x0000555555624e2c in d2x::songs_play_level_song(int, int) (levelnum=<optimized out>, offset=offset@entry=0) at similar/main/songs.cpp:749
#15 0x00005555555c5af7 in d2x::LoadLevel(int, int) (level_num=<optimized out>, page_in_textures=<optimized out>) at similar/main/gameseq.cpp:1111
#16 0x00005555555c76c3 in d2x::StartNewLevelSub(std::array<d2x::robot_info, 85ul> const&, int, int, d2x::secret_restore)
    (Robot_info=..., level_num=2, page_in_textures=<optimized out>, secret_flag=d2x::secret_restore::none) at similar/main/gameseq.cpp:2004
#17 0x00005555555c8212 in d2x::StartNewLevel(int) (level_num=2) at similar/main/gameseq.cpp:2225
#18 d2x::(anonymous namespace)::AdvanceLevel() () at similar/main/gameseq.cpp:1850
#19 0x00005555555c8352 in d2x::PlayerFinishedLevel() () at similar/main/gameseq.cpp:1710
#20 0x00005555555aa975 in d2x::start_endlevel_sequence() () at similar/main/endlevel.cpp:747
#21 0x000055555562cc56 in d2x::check_trigger_sub(d2x::object&, trgnum_t, unsigned int, unsigned int) (plrobj=<optimized out>, trigger_num=<optimized out>, pnum=<optimized out>, shot=0)
    at similar/main/switch.cpp:396
#22 0x000055555562ce14 in d2x::check_trigger(valptridx<dcx::segment>::ptridx<valptridx<dcx::segment>::vc>, dcx::sidenum_t, d2x::object&, valptridx<d2x::object>::ptridx<valptridx<d2x::object>::vc>, int)
    (seg=..., side=<optimized out>, plrobj=..., objnum=..., shot=0) at similar/main/switch.cpp:562
#23 0x00005555556136bf in d2x::(anonymous namespace)::object_move_one(d2x::d_level_shared_robot_info_state const&, d2x::vmobjptridx_t, d2x::control_info&)
    (LevelSharedRobotInfoState=<optimized out>, obj=..., Controls=<optimized out>) at similar/main/object.cpp:1961
#24 0x0000555555613c13 in d2x::(anonymous namespace)::object_move_all(d2x::d_level_shared_robot_info_state const&) (LevelSharedRobotInfoState=...) at similar/main/object.cpp:2095
#25 0x00005555555b5fde in d2x::(anonymous namespace)::GameProcessFrame (LevelSharedRobotInfoState=<optimized out>) at similar/main/game.cpp:2071
#26 d2x::game_window::event_handler(dcx::d_event const&) (this=<optimized out>, event=<optimized out>) at similar/main/game.cpp:1816
#27 0x00005555555794ff in dcx::window_send_event(dcx::window&, dcx::d_event const&) (event=..., wind=...) at common/include/window.h:74
#28 dcx::event_process() () at common/arch/sdl/event.cpp:252
#29 0x00005555555743a4 in d2x::(anonymous namespace)::main
    (argv_gd$b32$GAXDMMBOGAWWEZLUMEZC2MRRGIZC2Z3FGNTGCYLCGA4DSOLCMMzzzzzz=<optimized out>, argc_gc$archive_e3faab0899bc86184fdd67568ccc4f237c5f6807=<optimized out>) at similar/main/inferno.cpp:754
#30 main(int, char**) (argc_gc$archive_e3faab0899bc86184fdd67568ccc4f237c5f6807=<optimized out>, argv_gd$b32$GAXDMMBOGAWWEZLUMEZC2MRRGIZC2Z3FGNTGCYLCGA4DSOLCMMzzzzzz=<optimized out>)
    at similar/main/inferno.cpp:792

Edited to put stuff back in multiline code block.

@vLKp
Copy link
Contributor

vLKp commented Oct 21, 2022

Please use a multiline code block for pasting backtraces, to prevent Github becoming confused by the symbols in the backtrace output.

#3 0x00007ffff7572b2a in delete_fluid_synth () at /usr/lib/x86_64-linux-gnu/libfluidsynth.so.2
#4 0x00007ffff7ec031b in fluidsynth_freesong () at /usr/lib/x86_64-linux-gnu/libSDL_mixer-1.2.so.0

You are using fluidsynth and SDL1-mixer. As I understand issue #614, that is the same combination that caused memory corruption and crashes there. The solutions are the same: use SDL2-mixer, disable fluidsynth, or patch SDL1-mixer not to misuse fluidsynth. The best I could do in Rebirth would be to try to detect use of fluidsynth with SDL1 and disable music entirely. I don't know how viable that is, and it would punish anyone who installs a fixed version of SDL1-mixer. Since SDL2 handles fluidsynth properly, I am not strongly inclined to try to detect and block the bad combination. If you would like to propose a patch to do so, I will review it.

@BryanFRitt
Copy link
Author

BryanFRitt commented Oct 21, 2022

Tried the scons d2x=sdl2 sdl2_sdl2=1 (run from extracted directory) solution to this.
It fixes the issue, but doing so has some other issues like AA isn't working, there's no resolution list, switching resolutions requires one to type in the resolution, and having to do some extra alt+enter.

@vLKp
Copy link
Contributor

vLKp commented Oct 22, 2022

SDL2 does not define SDL_ListModes, so the code that would use it and then tell you what resolutions it returned is compiled out.

@vLKp
Copy link
Contributor

vLKp commented Nov 26, 2022

Comments from the original poster indicate that this crash is not a problem in SDL2, which is consistent with SDL2 being fixed to work with fluidsynth. There is nothing I can do in Rebirth to make SDL1 use fluidsynth correctly. I suggest contacting the distribution maintainers and asking them to either patch SDL1 to handle this or patch SDL1 not to allow use of fluidsynth.

Closing, since there is nothing more to do here.

@vLKp vLKp closed this as completed Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants