Calling viewer->update() immediately after viewer::create() crashes
Closed this issue · 3 comments
Describe the bug
viewer::update()
references _frameStamp()
which is not initialized in the constructor. Thus calling viewer->update()
immediately after Viewer::create()
causes program to crash.
To Reproduce
Compile and run the following code:
auto viewer = vsg::Viewer::create();
viewer->update();
Expected behavior
No crash
Desktop (please complete the following information):
- OS: Linux
- Version: commit:8a229b30637eea6fcfd9ace3d0745415dd563d7a
Additional context
The problem is worked around (_frameStamp()
is initialized) if the function viewer->advanceToNextFrame()
is called immediately after vsg::Viewer::create()
.
Also note that I only tested this with vsgQt:Viewer
but since the uninitialized variable access is in VulkanSceneGraph Viewer.cpp , I believe the problem occurs everywhere.
Another question you may ask is why I need to call update()
so early. The reason is that it was called indirectly during the Qt initialization, because I had bound a function (which is also used elsewhere) to a Qt event, which when triggered called the update()
function.
I'm currently thinking that initializing FrameStamp in the Viewer constructor would be the way to avoid this issue. I will review the code today.
I have moved the _frameStamp initialization into the Viewer constructor with commit:7a4950f672cc6640cb08f55fbd1b260da6b816a6 which is now part of VSG master. Could you please test. Thanks.
Thanks. This fixes the crash.