Why does Valgrind not like my usage of glutCreateWindow?

这一生的挚爱 提交于 2019-12-02 08:07:25

问题


I'm using the following code...

169: const char *title = Title.c_str();
170: glutCreateWindow(title);

... Valgrind gives me the following ...

==28841== Conditional jump or move depends on uninitialised value(s)
==28841==    at 0x6FF7A4C: (within /usr/lib64/libGLcore.so.180.44)
==28841==    by 0x6FF81F7: (within /usr/lib64/libGLcore.so.180.44)
==28841==    by 0x7289B36: (within /usr/lib64/libGLcore.so.180.44)
==28841==    by 0x728A757: _nv000133gl (in /usr/lib64/libGLcore.so.180.44)
==28841==    by 0x4EAB9E9: (within /usr/lib64/libGL.so.180.44)
==28841==    by 0x4EAEA81: (within /usr/lib64/libGL.so.180.44)
==28841==    by 0x4EB1D81: (within /usr/lib64/libGL.so.180.44)
==28841==    by 0x4EA782B: glXCreateNewContext (in /usr/lib64/libGL.so.180.44)
==28841==    by 0x54DF9AA: fgOpenWindow (in /usr/lib64/libglut.so.3.8.0)
==28841==    by 0x54DE062: fgCreateWindow (in /usr/lib64/libglut.so.3.8.0)
==28841==    by 0x54DF300: glutCreateWindow (in /usr/lib64/libglut.so.3.8.0)
==28841==    by 0x4146CE: vimrid::glut::GlutApplication::Init() (GlutApplication.cpp:170)

But what is uninitialized? The title variable is initialized with the value of Title.c_str() and Title is a class member which is initialized in the constructor member initialization list...

class VimridApplication
{
    // ...

public:
    std::string Title;

    // ...
}

VimridApplication::VimridApplication() :
    Title("Untitled VimridApplication")
{
    // ...
}

class GlutApplication : public VimridApplication
{
    // ...
}

回答1:


Valgrind comes with some default error suppression, but that probably does not cover libCLcore.

The error-checking tools detect numerous problems in the base libraries, such as the GNU C library, and the X11 client libraries, which come pre-installed on your GNU/Linux system. You can't easily fix these, but you don't want to see these errors (and yes, there are many!) So Valgrind reads a list of errors to suppress at startup. A default suppression file is created by the ./configure script when the system is built.

You can create your own error suppressions that you know are irrelevant to your code.




回答2:


Just ignore this; as you can see, the uninitialized value is used way below your code in the OpenGL library, and it's probably not your data that's uninitialized. You might want to dig into it (it may still be a false positive), but you might as well leave it alone.



来源:https://stackoverflow.com/questions/766303/why-does-valgrind-not-like-my-usage-of-glutcreatewindow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!