Player icon indicating copy to clipboard operation
Player copied to clipboard

Player crashes when exiting when using FluidSynth

Open elsemieni opened this issue 3 years ago • 7 comments

Tested on Windows based 0.7.0 builds (master and own builds).

If player uses FluidSynth as audio backend, at least one MIDI is played and player exits, then it crashes with the following stack trace:

[Marco flotante] Player.exe!fluid_synth_check_finished_voices(_fluid_synth_t *) Línea 4828
	en C:\easyrpg\070\buildscripts\windows\vcpkg\buildtrees\fluidsynth-easyrpg\src\272d57e624-1ad5fab979.clean\src\synth\fluid_synth.c(4828)
Player.exe!fluid_synth_api_enter(_fluid_synth_t * synth) Línea 7785
	en C:\easyrpg\070\buildscripts\windows\vcpkg\buildtrees\fluidsynth-easyrpg\src\272d57e624-1ad5fab979.clean\src\synth\fluid_synth.c(7785)
Player.exe!fluid_synth_cc(_fluid_synth_t * synth, int chan, int num, int val) Línea 1583
	en C:\easyrpg\070\buildscripts\windows\vcpkg\buildtrees\fluidsynth-easyrpg\src\272d57e624-1ad5fab979.clean\src\synth\fluid_synth.c(1583)
Player.exe!FluidSynthDecoder::SendMidiMessage(unsigned int message) Línea 262
	en C:\easyrpg\070\player_sch\Player\src\decoder_fluidsynth.cpp(262)
Player.exe!AudioDecoderMidi::SendMessageToAllChannels(unsigned int midi_msg) Línea 331
	en C:\easyrpg\070\player_sch\Player\src\audio_decoder_midi.cpp(331)
Player.exe!AudioDecoderMidi::reset() Línea 369
	en C:\easyrpg\070\player_sch\Player\src\audio_decoder_midi.cpp(369)
Player.exe!AudioDecoderMidi::~AudioDecoderMidi() Línea 94
	en C:\easyrpg\070\player_sch\Player\src\audio_decoder_midi.cpp(94)
[Código externo]
[Marco flotante] Player.exe!std::default_delete<AudioDecoderBase>::operator()(AudioDecoderBase *) Línea 2402
	en C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\memory(2402)
[Marco flotante] Player.exe!std::unique_ptr<AudioDecoderBase,std::default_delete<AudioDecoderBase>>::{dtor}() Línea 2512
	en C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\memory(2512)
Player.exe!AudioResampler::~AudioResampler() Línea 231
	en C:\easyrpg\070\player_sch\Player\src\audio_resampler.cpp(231)
[Código externo]
Player.exe!_execute_onexit_table::__l2::<lambda>() Línea 206
	en minkernel\crts\ucrt\src\appcrt\startup\onexit.cpp(206)
Player.exe!__crt_seh_guarded_call<int>::operator()<void <lambda>(void),int <lambda>(void) &,void <lambda>(void)>(__acrt_lock_and_call::__l2::void <lambda>(void) && setup, _execute_onexit_table::__l2::int <lambda>(void) & action, __acrt_lock_and_call::__l2::void <lambda>(void) && cleanup) Línea 204
	en vccrt\vcruntime\inc\internal_shared.h(204)
[Marco flotante] Player.exe!__acrt_lock_and_call(const __acrt_lock_id) Línea 971
	en minkernel\crts\ucrt\inc\corecrt_internal.h(971)
Player.exe!_execute_onexit_table(_onexit_table_t * table) Línea 231
	en minkernel\crts\ucrt\src\appcrt\startup\onexit.cpp(231)
Player.exe!common_exit::__l2::<lambda>() Línea 232
	en minkernel\crts\ucrt\src\appcrt\startup\exit.cpp(232)
Player.exe!__crt_seh_guarded_call<void>::operator()<void <lambda>(void),void <lambda>(void) &,void <lambda>(void)>(__acrt_lock_and_call::__l2::void <lambda>(void) && setup, common_exit::__l2::void <lambda>(void) & action, __acrt_lock_and_call::__l2::void <lambda>(void) && cleanup) Línea 225
	en vccrt\vcruntime\inc\internal_shared.h(225)
[Marco flotante] Player.exe!__acrt_lock_and_call(const __acrt_lock_id) Línea 971
	en minkernel\crts\ucrt\inc\corecrt_internal.h(971)
Player.exe!common_exit(const int return_code, const _crt_exit_cleanup_mode cleanup_mode, const _crt_exit_return_mode return_mode) Línea 278
	en minkernel\crts\ucrt\src\appcrt\startup\exit.cpp(278)
Player.exe!exit(int return_code) Línea 293
	en minkernel\crts\ucrt\src\appcrt\startup\exit.cpp(293)
[Código externo]
kernel32.dll![Los marcos siguientes pueden no ser correctos o faltar, no se han cargado símbolos para kernel32.dll]

The crash seems to happen at Fluidsynth side, but apparently happen at accesing to already destroyed memory (I can be wrong).

I will not include this time a core dump since it's easy to reproduce this bug. However, if you need a one please teel me and I will be happy to upload one :)

elsemieni avatar Oct 31 '21 21:10 elsemieni

Worth for a 0.7.0.1 update. Shouldn't be too hard to fix :)

Ghabry avatar Nov 04 '21 13:11 Ghabry

@elsemieni Somehow it refuses to crash for me :/

Ghabry avatar Nov 14 '21 19:11 Ghabry

@Ghabry Interesting, it could be a OS specific issue. You tried on GNU/Linux or Win/VS? (I don't discard any Win11 issue but it would be rare... I will try to do additional testing to check).

elsemieni avatar Nov 14 '21 21:11 elsemieni

tested on Windows 10

Ghabry avatar Nov 14 '21 22:11 Ghabry

Tested lastest build Win64( (#1497 ). Test made:

  • Play a MIDI file with FluidSynth (put a soundfont on game and name it easyrpg.soundfont to make this work).
  • Exit Player.

When exiting, a coredump will be generated. Tested on Windows 11 and Windows 10 VM. Both crashed.

Including sample project with a soundfont and used player for crash, and a core dump as well: musicCrash.zip

elsemieni avatar Feb 04 '22 02:02 elsemieni

New update

  • It seems to crash only when Player exits while a MIDI is playing (in game, or in exiting in a title screen, when the music does not stop after fading out -> In fact does not fade out).
  • If you stop the music via BGM stop or resetting the game, Player does not crashes at exit.
  • If you just fadeout the BGM and exiting, Player also crashes at exit.

elsemieni avatar Feb 04 '22 03:02 elsemieni

@elsemieni Are you really sure that this is not fixed?

With 0.7 I do get a crash dump.

When I run it with a continuous build I do not get a crash dump.

Ghabry avatar Jul 10 '22 23:07 Ghabry

Will close this due to lack of feedback. Please comment here when it happens again.

Ghabry avatar Oct 09 '22 21:10 Ghabry