Navigation Menu

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

Valgrind warnings in GL::Implementation::State #505

Closed
xqms opened this issue Apr 29, 2021 · 4 comments
Closed

Valgrind warnings in GL::Implementation::State #505

xqms opened this issue Apr 29, 2021 · 4 comments

Comments

@xqms
Copy link
Contributor

xqms commented Apr 29, 2021

Hey, I just saw that a very simple application involving a single Texture2D gives warnings under valgrind during exit:

==973387== Conditional jump or move depends on uninitialised value(s)
==973387==    at 0x11FFA6: ~AbstractTexture (AbstractTexture.cpp:238)
==973387==    by 0x11FFA6: Magnum::GL::AbstractTexture::~AbstractTexture() (AbstractTexture.cpp:229)
==973387==    by 0x113F46: ~Texture (Texture.h:102)
==973387==    by 0x113F46: ~App (display_time.cpp:13)
==973387==    by 0x113F46: main (display_time.cpp:40)
==973387==  Uninitialised value was created by a heap allocation
==973387==    at 0x483C583: operator new[](unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==973387==    by 0x170D7F: operator() (ArrayTuple.cpp:158)
==973387==    by 0x170D7F: Corrade::Containers::ArrayTuple::ArrayTuple<Corrade::Containers::ArrayTuple::ArrayTuple(Corrade::Containers::ArrayView<Corrade::Containers::ArrayTuple::Item const> const&)::{lambda(unsigned long, unsigned long)#1}>(Corrade::Containers::ArrayView<Corrade::Containers::ArrayTuple::Item const> const&, Corrade::Containers::ArrayTuple::ArrayTuple(Corrade::Containers::ArrayView<Corrade::Containers::ArrayTuple::Item const> const&)::{lambda(unsigned long, unsigned long)#1}) [clone .isra.0] (ArrayTuple.h:424)
==973387==    by 0x170DC8: ArrayTuple (ArrayTuple.cpp:159)
==973387==    by 0x170DC8: Corrade::Containers::ArrayTuple::ArrayTuple(std::initializer_list<Corrade::Containers::ArrayTuple::Item>) (ArrayTuple.cpp:163)
==973387==    by 0x13BB60: Magnum::GL::Implementation::State::allocate(Magnum::GL::Context&, std::ostream*) (State.cpp:115)
==973387==    by 0x135184: Magnum::GL::Context::tryCreate(Magnum::GL::Context::Configuration const&) (Context.cpp:974)
==973387==    by 0x11649A: tryCreate (GLContext.h:157)
==973387==    by 0x11649A: Magnum::Platform::GlfwApplication::tryCreate(Magnum::Platform::GlfwApplication::Configuration const&, Magnum::Platform::GlfwApplication::GLConfiguration const&) (GlfwApplication.cpp:574)
==973387==    by 0x116BC5: Magnum::Platform::GlfwApplication::tryCreate(Magnum::Platform::GlfwApplication::Configuration const&) (GlfwApplication.cpp:318)
==973387==    by 0x116C9C: Magnum::Platform::GlfwApplication::create(Magnum::Platform::GlfwApplication::Configuration const&) (GlfwApplication.cpp:127)
==973387==    by 0x117350: Magnum::Platform::GlfwApplication::GlfwApplication(Magnum::Platform::GlfwApplication::Arguments const&, Magnum::Platform::GlfwApplication::Configuration const&) (GlfwApplication.cpp:69)
==973387==    by 0x1173EF: Magnum::Platform::GlfwApplication::GlfwApplication(Magnum::Platform::GlfwApplication::Arguments const&) (GlfwApplication.cpp:66)
==973387==    by 0x1140F6: App::App(Magnum::Platform::GlfwApplication::Arguments const&) (display_time.cpp:24)
==973387==    by 0x113F25: main (display_time.cpp:40)

Source: https://gist.github.com/xqms/184ffe67e4ac28674183c6ce563c09d9

I tried digging into the GL::Implementation::State myself, but there's scary ArrayTuple stuff there :D But I guess something is going wrong with the ValueInit tag on the textureBinding array?

Maybe I'll have time to investigate further this evening ;)

@mosra
Copy link
Owner

mosra commented Apr 29, 2021

Oooh.

scary ArrayTuple stuff

Yes :D

ASan didn't tell me a thing. I'll investigate.

@mosra mosra added this to the 2021.0a milestone Apr 29, 2021
@mosra mosra added this to TODO in GL via automation Apr 29, 2021
@mosra
Copy link
Owner

mosra commented Apr 29, 2021

No idea why it would complain. I have tests that verify constructors get called on ValueInit'd suballocations, so that should work.

Maybe it's Valgrind misdetecting this because most of the allocation before is not initialized? Does the warning disappear if you put the textureBinding array first in the list passed to the ArrayTuple constructor (so the manual initialization gets done at the start of the allocation already)?

@xqms
Copy link
Contributor Author

xqms commented Apr 29, 2021

Maybe it's Valgrind misdetecting this because most of the allocation before is not initialized?

Valgrind/memcheck supposedly tracks unintialized values at bit level, so that should not be the case. I'll dig deeper in any case...

@xqms
Copy link
Contributor Author

xqms commented Apr 29, 2021

Found it! It's a problem in Corrade, so I'll open an issue there.

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

No branches or pull requests

2 participants