为什么 Valgrind 不喜欢我对 glutCreateWindow 的使用?

发布于 2024-07-17 03:59:37 字数 1461 浏览 5 评论 0原文

我正在使用以下代码...

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

... Valgrind 给了我以下内容...

==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)

但是什么是未初始化的? title 变量用 Title.c_str() 的值初始化,Title 是一个类成员,在构造函数成员初始化列表中初始化......

class VimridApplication
{
    // ...

public:
    std::string Title;

    // ...
}

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

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

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
{
    // ...
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

樱娆 2024-07-24 03:59:37

Valgrind 带有一些默认的错误抑制功能,但这可能不包括 libCLcore。

错误检查工具可以检测基础库中的许多问题,例如预装在 GNU/Linux 系统上的 GNU C 库和 X11 客户端库。 您无法轻松修复这些错误,但您不想看到这些错误(是的,有很多错误!)因此 Valgrind 会在启动时读取要抑制的错误列表。 系统构建时,./configure 脚本会创建一个默认的抑制文件。

您可以创建您自己知道的错误抑制与您的代码无关。

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.

流云如水 2024-07-24 03:59:37

忽略这一点即可; 正如您所看到的,未初始化的值在 OpenGL 库中的代码下方使用,并且可能不是您的未初始化的数据。 您可能想深入研究它(它可能仍然是误报),但您最好不要管它。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文