Trying to understand valgrind output

Here is the valgrind output..

Conditional jump or move depends on uninitialised value(s)
in RingsWidget::UpdateSeekBar() in ringswidget.cpp:514
1: RingsWidget::UpdateSeekBar() in <a href="file:///media/dipesh/Documents/Qt-projects/NomadDesktop-build-Desktop-Debug/../NomadDesktop/ringswidget.cpp:514" >ringswidget.cpp:514</a>
2: RingsWidget::UpdateRings() in <a href="file:///media/dipesh/Documents/Qt-projects/NomadDesktop-build-Desktop-Debug/../NomadDesktop/ringswidget.cpp:138" >ringswidget.cpp:138</a>
3: RingsWidget::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) in <a href="file:///media/dipesh/Documents/Qt-projects/NomadDesktop-build-Desktop-Debug/moc_ringswidget.cpp:49" >/media/dipesh/Documents/Qt-projects/NomadDesktop-build-Desktop-Debug/moc_ringswidget.cpp:49</a>
4: QMetaObject::activate(QObject*, QMetaObject const*, int, void**) in /usr/lib/
5: QObject::event(QEvent*) in /usr/lib/
6: QApplicationPrivate::notify_helper(QObject*, QEvent*) in /usr/lib/
7: QApplication::notify(QObject*, QEvent*) in /usr/lib/
8: QCoreApplication::notifyInternal(QObject*, QEvent*) in /usr/lib/
9: /usr/lib/
10: /usr/lib/
11: g_main_context_dispatch in /usr/lib/
12: /usr/lib/
13: g_main_context_iteration in /usr/lib/
14: QEventDispatcherGlib::processEvents(QFlags&lt;QEventLoop::ProcessEventsFlag&gt;) in /usr/lib/
15: /usr/lib/
16: QEventLoop::processEvents(QFlags&lt;QEventLoop::ProcessEventsFlag&gt;) in /usr/lib/
17: QEventLoop::exec(QFlags&lt;QEventLoop::ProcessEventsFlag&gt;) in /usr/lib/
18: QCoreApplication::exec() in /usr/lib/
19: main in <a href="file:///media/dipesh/Documents/Qt-projects/NomadDesktop-build-Desktop-Debug/../NomadDesktop/main.cpp:19" >main.cpp:19</a>

Uninitialised value was created by a heap allocation  1: operator new(unsigned long) in /usr/lib/valgrind/
2: MusicWidget::MusicWidget(QWidget*) in <a href="file:///media/dipesh/Documents/Qt-projects/NomadDesktop-build-Desktop-Debug/../NomadDesktop/musicwidget.cpp:148" >musicwidget.cpp:148</a>
3: NomadWindow::Initialize() in <a href="file:///media/dipesh/Documents/Qt-projects/NomadDesktop-build-Desktop-Debug/../NomadDesktop/nomadwindow.cpp:127" >nomadwindow.cpp:127</a>
4: NomadWindow::NomadWindow(QWidget*) in <a href="file:///media/dipesh/Documents/Qt-projects/NomadDesktop-build-Desktop-Debug/../NomadDesktop/nomadwindow.cpp:27" >nomadwindow.cpp:27</a>
5: main in <a href="file:///media/dipesh/Documents/Qt-projects/NomadDesktop-build-Desktop-Debug/../NomadDesktop/main.cpp:15" >main.cpp:15</a>

Here is the code..

511 NomadWindow *par = (NomadWindow*)parent();
512 float percentage = par->GetMusicWidget()->GetMPDSeekPerc();
513 settings[5].operator []("value") = percentage;
514 if ( percentage < 0.2 )
515     settings[5].operator []("fg_alpha") = 0.2;
516 else
517     settings[5].operator []("fg_alpha") = percentage;

The valgrind output is from the line 514 if ( percentage < 0.2 )

What is it that i'm doing wrong? Thanks in advance..


It looks as if valgrind propagates the use of the uninitialized value accessed in GetMPDSeekPerc() and reports an error when the uninitialized value is actually used for something rather than than just passing it along. The message about Uninitialised value was created by a heap allocation ... quite bluntly points to where the uninitialized value is coming from.

Conditional jump or move depends on uninitialised value(s)

This means in general that you have an if that tests a value that is not initialized. The result of the if is therefore random.

To go further you need to know where this variable is allocated/declared. You can get this information from :

Uninitialised value was created by a heap allocation 1: operator new(unsigned long) in ... MusicWidget::MusicWidget(QWidget*) in [...] musicwidget.cpp:148

That means that in musicwidget.cpp, line 148, you make a new on a int (the percentage) but you don't initialize it. You should find you error there.

Off topic: using new on an int usually not a good idea. Rather declare it as a variable if possible

Need Your Help

Too many comps of type “BUFGMUX” found to fit this device. (Ethernet Design)

vhdl fpga xilinx

I'm designing an Ethernet MAC Controller for Spartan 3E FPGA. IOBs have reached 109%. I still proceeded with the generation of bitstream. I then encountered this error: