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

how to display the database name and change the database properties in java (spring framework)

database spring java-ee

I have a requirement to display the database name on the screen that is connected by the web application (which is configured through the datasource on weblogic server with spring data xml having ...

iOS how to identify which image (button) is pressed?

objective-c ios uibutton uiimage

I've three randomly generated images( actually UIButton) and when application runs it asks the user to choose one random image among the three(say a.png).after user select the image app will do some

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.