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

Note Off + Detune Effect causes uninitialised values #166

Closed
OPNA2608 opened this issue Nov 25, 2019 · 1 comment
Closed

Note Off + Detune Effect causes uninitialised values #166

OPNA2608 opened this issue Nov 25, 2019 · 1 comment

Comments

@OPNA2608
Copy link
Member

Reproduction steps (tested on 497621c):

  1. Load this module.
  2. Click Play.

Debugging with valgrind --trace-children=yes --track-origins=yes shows:

==28080== Conditional jump or move depends on uninitialised value(s)
==28080==    at 0x1E4AAB: PitchConverter::calculateIndex(int, Note, int) (pitch_converter.hpp:26)
==28080==    by 0x1E4856: PitchConverter::getPitchFM(Note, int, int) (pitch_converter.cpp:5)
==28080==    by 0x245E4C: OPNAController::writePitchFM(int) (opna_controller.cpp:1922)
==28080==    by 0x244C5B: OPNAController::tickEventFM(int) (opna_controller.cpp:1718)
==28080==    by 0x23B728: OPNAController::tickEvent(SoundSource, int) (opna_controller.cpp:58)
==28080==    by 0x1D5331: PlaybackManager::tickProcess(int) (playback.cpp:1078)
==28080==    by 0x1D188F: PlaybackManager::streamCountUp() (playback.cpp:184)
==28080==    by 0x1A98EF: BambooTracker::streamCountUp() (bamboo_tracker.cpp:1246)
==28080==    by 0x14C519: MainWindow::MainWindow(std::weak_ptr<Configuration>, QString, QWidget*)::{lambda(void*)#20}::operator()(void*) const (mainwindow.cpp:406)
==28080==    by 0x14C538: MainWindow::MainWindow(std::weak_ptr<Configuration>, QString, QWidget*)::{lambda(void*)#20}::_FUN(void*) (mainwindow.cpp:407)
==28080==    by 0x1DE483: AudioStream::generateTick() (audio_stream.cpp:112)
==28080==    by 0x1DE3A7: AudioStream::generate(short*, unsigned int) (audio_stream.cpp:97)
==28080==  Uninitialised value was created by a heap allocation
==28080==    at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==28080==    by 0x1C9F52: __gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<OPNAController, std::allocator<OPNAController>, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long, void const*) (new_allocator.h:111)
==28080==    by 0x1C8638: std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<OPNAController, std::allocator<OPNAController>, (__gnu_cxx::_Lock_policy)2> > >::allocate(std::allocator<std::_Sp_counted_ptr_inplace<OPNAController, std::allocator<OPNAController>, (__gnu_cxx::_Lock_policy)2> >&, unsigned long) (alloc_traits.h:436)
==28080==    by 0x1C58E7: std::__allocated_ptr<std::allocator<std::_Sp_counted_ptr_inplace<OPNAController, std::allocator<OPNAController>, (__gnu_cxx::_Lock_policy)2> > > std::__allocate_guarded<std::allocator<std::_Sp_counted_ptr_inplace<OPNAController, std::allocator<OPNAController>, (__gnu_cxx::_Lock_policy)2> > >(std::allocator<std::_Sp_counted_ptr_inplace<OPNAController, std::allocator<OPNAController>, (__gnu_cxx::_Lock_policy)2> >&) (allocated_ptr.h:104)
==28080==    by 0x1C26AE: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<OPNAController, std::allocator<OPNAController>, chip::Emu, unsigned int const&, unsigned int, unsigned long>(std::_Sp_make_shared_tag, OPNAController*, std::allocator<OPNAController> const&, chip::Emu&&, unsigned int const&, unsigned int&&, unsigned long&&) (shared_ptr_base.h:635)
==28080==    by 0x1BEC7E: std::__shared_ptr<OPNAController, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<OPNAController>, chip::Emu, unsigned int const&, unsigned int, unsigned long>(std::_Sp_make_shared_tag, std::allocator<OPNAController> const&, chip::Emu&&, unsigned int const&, unsigned int&&, unsigned long&&) (shared_ptr_base.h:1295)
==28080==    by 0x1BAE20: std::shared_ptr<OPNAController>::shared_ptr<std::allocator<OPNAController>, chip::Emu, unsigned int const&, unsigned int, unsigned long>(std::_Sp_make_shared_tag, std::allocator<OPNAController> const&, chip::Emu&&, unsigned int const&, unsigned int&&, unsigned long&&) (shared_ptr.h:344)
==28080==    by 0x1B5CE3: std::shared_ptr<OPNAController> std::allocate_shared<OPNAController, std::allocator<OPNAController>, chip::Emu, unsigned int const&, unsigned int, unsigned long>(std::allocator<OPNAController> const&, chip::Emu&&, unsigned int const&, unsigned int&&, unsigned long&&) (shared_ptr.h:691)
==28080==    by 0x1AEA12: std::shared_ptr<OPNAController> std::make_shared<OPNAController, chip::Emu, unsigned int const&, unsigned int, unsigned long>(chip::Emu&&, unsigned int const&, unsigned int&&, unsigned long&&) (shared_ptr.h:707)
==28080==    by 0x1A2A6A: BambooTracker::BambooTracker(std::weak_ptr<Configuration>) (bamboo_tracker.cpp:25)
==28080==    by 0x18E853: void __gnu_cxx::new_allocator<BambooTracker>::construct<BambooTracker, std::weak_ptr<Configuration>&>(BambooTracker*, std::weak_ptr<Configuration>&) (new_allocator.h:136)
==28080==    by 0x18D7FD: void std::allocator_traits<std::allocator<BambooTracker> >::construct<BambooTracker, std::weak_ptr<Configuration>&>(std::allocator<BambooTracker>&, BambooTracker*, std::weak_ptr<Configuration>&) (alloc_traits.h:475)

If I print that function's arguments (int octave, Note note, int pitch) and the idx variable to std::cout, I get a very similar warning (caused by the printing) for the following:

  • idx (expectedly)
  • note
  • pitch

I can't replicate those warnings without the Detune effect (copied from Rude Buster.btm, FM4, very first bar). It prolly doesn't cause any actual problems with playback, but the fewer warnings the better. 🙂

@OPNA2608 OPNA2608 changed the title Note Off + Detune Effect causes uninitialised value Note Off + Detune Effect causes uninitialised values Nov 25, 2019
@rerrahkr
Copy link
Member

Thank you for your report.
I forgot to initialize keyToneFM_.note, keyToneFM_.pitch, keyToneSSG_.note and keyToneSSG_.pitch. It was fixed at 3fcc664. In this commit, I also fixed that the task of FM&SSG pitch update before the first note event is skipped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants