EasyRPG / Player

RPG Maker 2000/2003 and EasyRPG games interpreter
https://easyrpg.org/player/
GNU General Public License v3.0
1.01k stars 191 forks source link

Segmentation fault on exit when compiled with -DPLAYER_WITH_FLUIDSYNTH=yes and >= -O1 #3079

Closed antecrescent closed 1 year ago

antecrescent commented 1 year ago

Name of the game:

TestGame-2000

Player platform:

Linux am64, not CI build (neither Flatpak nor static bundle)

Attach files (as a .zip archive or link them)

easyrpg_log.txt

Describe the issue in detail and how to reproduce it:

I am trying to debug a segmentation fault on my local build that I cannot reproduce with the CI builds. Curiously, it only occurs when compiled with >= -O1. What compiler flags are used for the Linux CI builds?

If anyone is interested in helping me debug this local issue, here is some further info: Steps to reproduce:

  1. Compile with -DPLAYER_WITH_FLUIDSYNTH=yes -O1
  2. cd TestGame-2000/
  3. easyplayer-rpg
  4. Press 'End'

Step 2 is important here. If I run the executable from another directory and navigate to the game in the player, I can exit normally.

Backtrace:

#0  ___pthread_mutex_lock (mutex=0x555000f8c061) at pthread_mutex_lock.c:80
#1  0x00007ffff75ca88d in fluid_synth_api_enter (synth=synth@entry=0x5555561516c0)
    at /usr/src/debug/media-sound/fluidsynth-2.3.3/fluidsynth-2.3.3/src/synth/fluid_synth.c:7813
#2  0x00007ffff75d2b2b in fluid_synth_cc (synth=0x5555561516c0, chan=0, num=120, val=0)
    at /usr/src/debug/media-sound/fluidsynth-2.3.3/fluidsynth-2.3.3/src/synth/fluid_synth.c:1592
#3  0x00005555555d9ffe in AudioDecoderMidi::SendMessageToAllChannels (midi_msg=30896,
    this=0x555556142d40)
    at /usr/src/debug/games-engines/easyrpg-player-0.8/easyrpg-player-0.8/src/audio_decoder_midi.cpp:339
#4  AudioDecoderMidi::reset (this=this@entry=0x555556142d40)
    at /usr/src/debug/games-engines/easyrpg-player-0.8/easyrpg-player-0.8/src/audio_decoder_midi.cpp:376
#5  0x00005555555da0e6 in AudioDecoderMidi::~AudioDecoderMidi (this=0x555556142d40,
    __in_chrg=<optimized out>)
    at /usr/src/debug/games-engines/easyrpg-player-0.8/easyrpg-player-0.8/src/audio_decoder_midi.cpp:94
#6  0x00005555555da209 in AudioDecoderMidi::~AudioDecoderMidi (this=0x555556142d40,
    __in_chrg=<optimized out>)
    at /usr/src/debug/games-engines/easyrpg-player-0.8/easyrpg-player-0.8/src/audio_decoder_midi.cpp:95
#7  0x00005555555deb42 in std::default_delete<AudioDecoderBase>::operator() (__ptr=0x555556142d40,
    this=<optimized out>) at /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/unique_ptr.h:95
#8  std::unique_ptr<AudioDecoderBase, std::default_delete<AudioDecoderBase> >::~unique_ptr (
    this=0x55555654eb20, __in_chrg=<optimized out>)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/unique_ptr.h:396
#9  AudioResampler::~AudioResampler (this=0x55555654ead0, __in_chrg=<optimized out>)
    at /usr/src/debug/games-engines/easyrpg-player-0.8/easyrpg-player-0.8/src/audio_resampler.cpp:231
#10 0x00005555555deb59 in AudioResampler::~AudioResampler (this=0x55555654ead0,
    __in_chrg=<optimized out>)
    at /usr/src/debug/games-engines/easyrpg-player-0.8/easyrpg-player-0.8/src/audio_resampler.cpp:231
#11 0x00007ffff7137f84 in __run_exit_handlers (status=0, listp=0x7ffff72c7660 <__exit_funcs>,
    run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:111
#12 0x00007ffff71380bc in __GI_exit (status=<optimized out>) at exit.c:141
#13 0x00007ffff71208d3 in __libc_start_call_main (main=main@entry=0x5555555c9360 <main(int, char**)>,
    argc=argc@entry=1, argv=argv@entry=0x7fffffffd478) at ../sysdeps/nptl/libc_start_call_main.h:74
#14 0x00007ffff7120985 in __libc_start_main_impl (main=0x5555555c9360 <main(int, char**)>, argc=1,
    argv=0x7fffffffd478, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,
    stack_end=0x7fffffffd468) at ../csu/libc-start.c:360
#15 0x00005555555c94c1 in _start ()

My configuration:

cmake -C /var/tmp/portage/games-engines/easyrpg-player-0.8/work/easyrpg-player-0.8_build/gentoo_common_config.cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=/var/tmp/portage/games-engines/easyrpg-player-0.8/work/easyrpg-player-0.8_build/gentoo_toolchain.cmake /var/tmp/portage/games-engines/easyrpg-player-0.8/work/easyrpg-player-0.8
loading initial cache file /var/tmp/portage/games-engines/easyrpg-player-0.8/work/easyrpg-player-0.8_build/gentoo_common_config.cmake
-- The CXX compiler identification is GNU 12.3.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/x86_64-pc-linux-gnu-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Build type is set to RelWithDebInfo.
-- Found SDL2: /usr/lib64/cmake/SDL2 (SDL2::SDL2)
-- Found the following ICU libraries:
--   i18n (required): /usr/lib64/libicui18n.so
--   uc (required): /usr/lib64/libicuuc.so
--   data (required): /usr/lib64/libicudata.so
-- Found ICU: /usr/include (found version "73.2")
-- Found liblcf: /usr/lib64/cmake/liblcf (liblcf::liblcf)
-- Found ZLIB: /usr/lib64/libz.so (found version "1.2.13")
-- Found PNG: /usr/lib64/libpng.so (found version "1.6.40+apng")
-- Found fmt: /usr/lib64/cmake/fmt (fmt::fmt)
-- Found Pixman: /usr/lib64/libpixman-1.so
-- Found freetype: /usr/lib64/libfreetype.so (found version "2.13.0")
-- Found harfbuzz: /usr/lib64/libharfbuzz.so
-- Found ALSA: /usr/lib64/libasound.so (found version "1.2.9")
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found speexdsp: /usr/lib64/libspeexdsp.so
-- Found mpg123: /usr/lib64/libmpg123.so
-- Found SndFile: /usr/lib64/libsndfile.so
-- Found Vorbis: /usr/lib64/libvorbisfile.so
-- Found Opusfile: /usr/lib64/libopusfile.so
-- Found WildMidi: /usr/lib64/cmake/WildMidi (WildMidi::libwildmidi)
-- Found FluidSynth: /usr/lib64/cmake/fluidsynth (FluidSynth::libfluidsynth)
-- Found XMP: /usr/lib64/libxmp.so (found suitable version "4.5.0", minimum required is "4.5.0")
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
--
-- Target system: SDL2
--
-- Audio backend: SDL2
--
-- WAV playback: built-in (dr_wav);libsndfile
-- MIDI playback: FluidSynth;WildMidi;Native;built-in (FmMidi)
-- MP3 playback: mpg123
-- Ogg Vorbis playback: libvorbis
-- MOD playback: libxmp
-- Opus playback: opusfile
-- Resampler: speexdsp
--
-- Font rendering: Freetype with Harfbuzz / built-in
--
-- Manual page: Bundled
-- Bash completion: Available
-- Doxygen: Unavailable
--
-- <<< Gentoo configuration >>>
Build type      RelWithDebInfo
Install path    /usr
Compiler flags:
C
C++             -march=native -O1 -pipe
Linker flags:
Executable      -Wl,-O1 -Wl,--as-needed
Module          -Wl,-O1 -Wl,--as-needed
Shared          -Wl,-O1 -Wl,--as-needed
Ghabry commented 1 year ago

I think this is a duplicate of #3035 . I get the same stacktrace on Windows but even in the debug build, making my life easier here :D

antecrescent commented 1 year ago

Thanks, that fixes it!