libgme / game-music-emu

Blargg's video game music emulation library, which allows audio applications to easily add playback support for the music of many classic video game consoles.
GNU Lesser General Public License v2.1
59 stars 12 forks source link

valgrind warning in spc code #57

Closed sezero closed 9 months ago

sezero commented 9 months ago

FYI:

==14312== Conditional jump or move depends on uninitialised value(s)
==14312==    at 0x41DB946: Spc_Dsp::update_voice_vol(int) (Spc_Dsp.h:173)
==14312==    by 0x41E05EC: Spc_Dsp::mute_voices(int) (Spc_Dsp.cpp:657)
==14312==    by 0x41E0626: Spc_Dsp::init(void*) (Spc_Dsp.cpp:664)
==14312==    by 0x41DACAC: Snes_Spc::init() (Snes_Spc.cpp:35)
==14312==    by 0x41E1406: Spc_Emu::set_sample_rate_(long) (Spc_Emu.cpp:402)
==14312==    by 0x41AC8E6: Music_Emu::set_sample_rate(long) (Music_Emu.cpp:86)
==14312==    by 0x41A8F7A: gme_internal_new_emu_(gme_type_t_ const*, int, bool) (gme.cpp:250)
==14312==    by 0x41A8FC8: gme_new_emu (gme.cpp:264)
==14312==    by 0x41A8CCF: gme_open_file (gme.cpp:190)
==14312==    by 0x804A328: Music_Player::load_file(char const*, bool) (Music_Player.cpp:115)
==14312==    by 0x804AC2A: main (player.cpp:121)
sezero commented 9 months ago

Not sure how reliable the trace is, though..

Wohlstand commented 9 months ago

Should be easily fixed by adding next constructor:

Spc_Dsp::Spc_Dsp()
{
    memset(&m, 0, sizeof(state_t));
}
Wohlstand commented 9 months ago

I done a thing, please verify.

sezero commented 9 months ago

FYI: To reproduce, I had to build the library in debug mode, i.e. with -DCMAKE_BUILD_TYPE=Debug

In any case: After https://github.com/libgme/game-music-emu/commit/7ed447d78213a1e9885de96269fd512f4dae728b, valgrind seems silent. So I think you can close this.