Random skybox texture(?) loading crash


#1

After adding rudimentary caching (Resource caching doesn't work) myself, my program now randomly crashes on startup with this callstack:

0  in bs::ct::GLTexture::getBuffer of /home/hhyyrylainen/Projects/Leviathan/ThirdParty/bsf/Source/Plugins/bsfGLRenderAPI/BsGLTexture.cpp:539
1  in bs::ct::GLRenderTexture::initialize of /home/hhyyrylainen/Projects/Leviathan/ThirdParty/bsf/Source/Foundation/bsfCore/RenderAPI/BsTextureView.h:75
2  in bs::ct::TextureManager::createRenderTexture of /usr/include/c++/8/bits/shared_ptr_base.h:1018
3  in bs::ct::RenderTexture::create of /home/hhyyrylainen/Projects/Leviathan/ThirdParty/bsf/Source/Foundation/bsfCore/RenderAPI/BsRenderTexture.cpp:230
4  in bs::ct::RenderBeastIBLUtility::downsampleCubemap of /home/hhyyrylainen/Projects/Leviathan/ThirdParty/bsf/Source/Plugins/bsfRenderBeast/BsRenderBeastIBLUtility.cpp:586
5  in bs::ct::RenderBeastIBLUtility::scaleCubemap of /home/hhyyrylainen/Projects/Leviathan/ThirdParty/bsf/Source/Plugins/bsfRenderBeast/BsRenderBeastIBLUtility.cpp:572
6  in bs::Skybox::<lambda()>::operator() of /usr/include/c++/8/ext/atomicity.h:96
7  in std::_Function_handler<bool(), bs::Skybox::filterTexture()::<lambda()> >::_M_invoke(const std::_Any_data &) of /usr/include/c++/8/bits/std_function.h:282
8  in std::function<bool ()>::operator()() const of /usr/include/c++/8/bits/std_function.h:682
9  in bs::ct::Renderer::<lambda()>::operator() of /home/hhyyrylainen/Projects/Leviathan/ThirdParty/bsf/Source/Foundation/bsfCore/Renderer/BsRenderer.cpp:113
10 in bs::ct::Renderer::processTasks of /home/hhyyrylainen/Projects/Leviathan/ThirdParty/bsf/Source/Foundation/bsfCore/Renderer/BsRenderer.cpp:114
11 in bs::ct::RenderBeast::renderAllCore of /home/hhyyrylainen/Projects/Leviathan/ThirdParty/bsf/Source/Plugins/bsfRenderBeast/BsRenderBeast.cpp:393
12 in std::function<void ()>::operator()() const of /usr/include/c++/8/bits/std_function.h:682
13 in bs::CommandQueueBase::playbackWithNotify(std::queue<bs::QueuedCommand, std::deque<bs::QueuedCommand, bs::StdAlloc<bs::QueuedCommand, bs::GenAlloc> > >*, std::function<void (unsigned int)>) of /home/hhyyrylainen/Projects/Leviathan/ThirdParty/bsf/Source/Foundation/bsfCore/CoreThread/BsCommandQueue.cpp:126
14 in bs::CommandQueueBase::playback of /usr/include/c++/8/bits/std_function.h:395
15 in std::function<void ()>::operator()() const of /usr/include/c++/8/bits/std_function.h:682
16 in bs::CommandQueueBase::playbackWithNotify(std::queue<bs::QueuedCommand, std::deque<bs::QueuedCommand, bs::StdAlloc<bs::QueuedCommand, bs::GenAlloc> > >*, std::function<void (unsigned int)>) of /home/hhyyrylainen/Projects/Leviathan/ThirdParty/bsf/Source/Foundation/bsfCore/CoreThread/BsCommandQueue.cpp:126
17 in bs::CoreThread::runCoreThread of /usr/include/c++/8/bits/std_function.h:87
18 in std::function<void ()>::operator()() const of /usr/include/c++/8/bits/std_function.h:682
19 in bs::PooledThread::run of /home/hhyyrylainen/Projects/Leviathan/ThirdParty/bsf/Source/Foundation/bsfUtility/Threading/BsThreadPool.cpp:115
20 in ?? of /lib64/libstdc++.so.6
21 in start_thread of /lib64/libpthread.so.0
22 in clone of /lib64/libc.so.6

This is on Linux with OpenGL render system.

Looking at the texture details it seems like the texture data hasn’t been loaded yet (me adding that basic caching may have improved the startup performance resulting in the texture data not being ready):

Thread 50 "Thrive" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffef9999700 (LWP 10979)]
bs::ct::GLTexture::getBuffer (this=this@entry=0xaee8c00, face=0, mipmap=0) at /home/hhyyrylainen/Projects/Leviathan/ThirdParty/bsf/Source/Plugins/bsfGLRenderAPI/BsGLTexture.cpp:539
539			return mSurfaceList[idx];
mSurfaceList[idx] = Cannot access memory at address 0x0
p mSurfaceList
$1 = std::vector of length 0, capacity 0

Of course I’m not ruling out the possibility that I accidentally broke something when tweaking my model assets…


#2

I can’t tell what exactly is going wrong but I doubt it’s an error in your code. If you can submit a complete example I can easily compile and test I can debug it for you.


#3

I got a different crash when I tried to use the samples to trigger this problem.
This is the code I changed in the examples:

diff --git a/Source/SkeletalAnimation/Main.cpp b/Source/SkeletalAnimation/Main.cpp
index 3c9b87a..778d3a9 100644
--- a/Source/SkeletalAnimation/Main.cpp
+++ b/Source/SkeletalAnimation/Main.cpp
@@ -88,7 +88,8 @@ namespace bs
                assets.exampleMaterial->setTexture("gMetalnessTex", assets.exampleMetalnessTex);
 
                // Load an environment map
-               assets.exampleSkyCubemap = ExampleFramework::loadTexture(ExampleTexture::EnvironmentRathaus, false, true, true);
+        assets.exampleSkyCubemap = bs::gResources().load<bs::Texture>(exampleDataPath + "Materials/Thrive_ocean_skybox.asset");
+        // assets.exampleSkyCubemap = ExampleFramework::loadTexture(ExampleTexture::EnvironmentRathaus, false, true, true);
 
                return assets;
        }
@@ -212,4 +213,4 @@ int main()
        Application::shutDown();
 
        return 0;
-}
\ No newline at end of file
+}

Here’s the asset file: https://boostslair.com/files/temp/thrive/Thrive_ocean_skybox.asset

This is the crash:

0  in ?? of /lib64/libnvidia-glcore.so.430.40
1  in ?? of /lib64/libnvidia-glcore.so.430.40
2  in ?? of /lib64/libnvidia-glcore.so.430.40
3  in ?? of /lib64/libnvidia-glcore.so.430.40
4  in ?? of /lib64/libnvidia-glcore.so.430.40
5  in ?? of /lib64/libnvidia-glcore.so.430.40
6  in ?? of /lib64/libnvidia-glcore.so.430.40
7  in bs::ct::GLTextureBuffer::upload of /home/hhyyrylainen/Projects/bsfExamples/bsf/Source/Plugins/bsfGLRenderAPI/BsGLPixelBuffer.cpp:263
8  in bs::ct::GLTexture::writeDataImpl of /home/hhyyrylainen/Projects/bsfExamples/bsf/Source/Plugins/bsfGLRenderAPI/BsGLTexture.cpp:445
9  in bs::ct::Texture::writeData of /home/hhyyrylainen/Projects/bsfExamples/bsf/Source/Foundation/bsfCore/Image/BsTexture.cpp:358
10 in bs::Texture::<lambda(bs::SPtr<bs::ct::Texture>&, bs::UINT32, bs::UINT32, bs::SPtr<bs::PixelData>&, bool, bs::AsyncOp&)>::operator()(const bs::SPtr &, bs::UINT32, bs::UINT32, const bs::SPtr &, bool, bs::AsyncOp &) const of /home/hhyyrylainen/Projects/bsfExamples/bsf/Source/Foundation/bsfCore/Image/BsTexture.cpp:127
11 in std::_Function_handler<void(const std::shared_ptr<bs::ct::Texture>&, unsigned int, unsigned int, const std::shared_ptr<bs::PixelData>&, bool, bs::AsyncOp&), bs::Texture::writeData(bs::SPtr<bs::PixelData>&, bs::UINT32, bs::UINT32, bool)::<lambda(bs::SPtr<bs::ct::Texture>&, bs::UINT32, bs::UINT32, bs::SPtr<bs::PixelData>&, bool, bs::AsyncOp&)> >::_M_invoke(const std::_Any_data &, const std::shared_ptr<bs::ct::Texture> &, unsigned int &&, unsigned int &&, const std::shared_ptr<bs::PixelData> &, bool &&, bs::AsyncOp &) of /usr/include/c++/8/bits/std_function.h:297
12 in std::function<void (std::shared_ptr<bs::ct::Texture> const&, unsigned int, unsigned int, std::shared_ptr<bs::PixelData> const&, bool, bs::AsyncOp&)>::operator()(std::shared_ptr<bs::ct::Texture> const&, unsigned int, unsigned int, std::shared_ptr<bs::PixelData> const&, bool, bs::AsyncOp&) const of /usr/include/c++/8/bits/std_function.h:687
13 in std::__invoke_impl<void, std::function<void (std::shared_ptr<bs::ct::Texture> const&, unsigned int, unsigned int, std::shared_ptr<bs::PixelData> const&, bool, bs::AsyncOp&)>&, std::shared_ptr<bs::ct::Texture>&, unsigned int&, unsigned int&, std::shared_ptr<bs::PixelData>&, bool&, bs::AsyncOp&>(std::__invoke_other, std::function<void (std::shared_ptr<bs::ct::Texture> const&, unsigned int, unsigned int, std::shared_ptr<bs::PixelData> const&, bool, bs::AsyncOp&)>&, std::shared_ptr<bs::ct::Texture>&, unsigned int&, unsigned int&, std::shared_ptr<bs::PixelData>&, bool&, bs::AsyncOp&) of /usr/include/c++/8/bits/invoke.h:60
14 in std::__invoke<std::function<void (std::shared_ptr<bs::ct::Texture> const&, unsigned int, unsigned int, std::shared_ptr<bs::PixelData> const&, bool, bs::AsyncOp&)>&, std::shared_ptr<bs::ct::Texture>&, unsigned int&, unsigned int&, std::shared_ptr<bs::PixelData>&, bool&, bs::AsyncOp&>(std::function<void (std::shared_ptr<bs::ct::Texture> const&, unsigned int, unsigned int, std::shared_ptr<bs::PixelData> const&, bool, bs::AsyncOp&)>&, std::shared_ptr<bs::ct::Texture>&, unsigned int&, unsigned int&, std::shared_ptr<bs::PixelData>&, bool&, bs::AsyncOp&) of /usr/include/c++/8/bits/invoke.h:95
15 in std::_Bind<std::function<void (std::shared_ptr<bs::ct::Texture> const&, unsigned int, unsigned int, std::shared_ptr<bs::PixelData> const&, bool, bs::AsyncOp&)> (std::shared_ptr<bs::ct::Texture>, unsigned int, unsigned int, std::shared_ptr<bs::PixelData>, bool, std::_Placeholder<1>)>::__call<void, bs::AsyncOp&, 0ul, 1ul, 2ul, 3ul, 4ul, 5ul>(std::tuple<bs::AsyncOp&>&&, std::_Index_tuple<0ul, 1ul, 2ul, 3ul, 4ul, 5ul>) of /usr/include/c++/8/functional:400
16 in std::_Bind<std::function<void (std::shared_ptr<bs::ct::Texture> const&, unsigned int, unsigned int, std::shared_ptr<bs::PixelData> const&, bool, bs::AsyncOp&)> (std::shared_ptr<bs::ct::Texture>, unsigned int, unsigned int, std::shared_ptr<bs::PixelData>, bool, std::_Placeholder<1>)>::operator()<bs::AsyncOp&, void>(bs::AsyncOp&) of /usr/include/c++/8/functional:484
17 in std::_Function_handler<void (bs::AsyncOp&), std::_Bind<std::function<void (std::shared_ptr<bs::ct::Texture> const&, unsigned int, unsigned int, std::shared_ptr<bs::PixelData> const&, bool, bs::AsyncOp&)> (std::shared_ptr<bs::ct::Texture>, unsigned int, unsigned int, std::shared_ptr<bs::PixelData>, bool, std::_Placeholder<1>)> >::_M_invoke(std::_Any_data const&, bs::AsyncOp&) of /usr/include/c++/8/bits/std_function.h:297
18 in std::function<void (bs::AsyncOp&)>::operator()(bs::AsyncOp&) const of /usr/include/c++/8/bits/std_function.h:687
19 in bs::CommandQueueBase::playbackWithNotify(std::queue<bs::QueuedCommand, std::deque<bs::QueuedCommand, bs::StdAlloc<bs::QueuedCommand, bs::GenAlloc> > >*, std::function<void (unsigned int)>) of /home/hhyyrylainen/Projects/bsfExamples/bsf/Source/Foundation/bsfCore/CoreThread/BsCommandQueue.cpp:113
20 in bs::CommandQueueBase::playback of /home/hhyyrylainen/Projects/bsfExamples/bsf/Source/Foundation/bsfCore/CoreThread/BsCommandQueue.cpp:140
21 in std::__invoke_impl<void, void (bs::CommandQueueBase::*&)(std::queue<bs::QueuedCommand, std::deque<bs::QueuedCommand, bs::StdAlloc<bs::QueuedCommand, bs::GenAlloc> > >*), bs::CommandQueueBase*&, std::queue<bs::QueuedCommand, std::deque<bs::QueuedCommand, bs::StdAlloc<bs::QueuedCommand, bs::GenAlloc> > >*&> of /usr/include/c++/8/bits/invoke.h:73
22 in std::__invoke<void (bs::CommandQueueBase::*&)(std::queue<bs::QueuedCommand, std::deque<bs::QueuedCommand, bs::StdAlloc<bs::QueuedCommand, bs::GenAlloc> > >*), bs::CommandQueueBase*&, std::queue<bs::QueuedCommand, std::deque<bs::QueuedCommand, bs::StdAlloc<bs::QueuedCommand, bs::GenAlloc> > >*&> of /usr/include/c++/8/bits/invoke.h:95
23 in std::_Bind<void (bs::CommandQueueBase::*(bs::CommandQueueBase*, std::queue<bs::QueuedCommand, std::deque<bs::QueuedCommand, bs::StdAlloc<bs::QueuedCommand, bs::GenAlloc> > >*))(std::queue<bs::QueuedCommand, std::deque<bs::QueuedCommand, bs::StdAlloc<bs::QueuedCommand, bs::GenAlloc> > >*)>::__call<void, , 0ul, 1ul>(std::tuple<>&&, std::_Index_tuple<0ul, 1ul>) of /usr/include/c++/8/functional:400
24 in std::_Bind<void (bs::CommandQueueBase::*(bs::CommandQueueBase*, std::queue<bs::QueuedCommand, std::deque<bs::QueuedCommand, bs::StdAlloc<bs::QueuedCommand, bs::GenAlloc> > >*))(std::queue<bs::QueuedCommand, std::deque<bs::QueuedCommand, bs::StdAlloc<bs::QueuedCommand, bs::GenAlloc> > >*)>::operator()<, void>() of /usr/include/c++/8/functional:484
25 in std::_Function_handler<void (), std::_Bind<void (bs::CommandQueueBase::*(bs::CommandQueueBase*, std::queue<bs::QueuedCommand, std::deque<bs::QueuedCommand, bs::StdAlloc<bs::QueuedCommand, bs::GenAlloc> > >*))(std::queue<bs::QueuedCommand, std::deque<bs::QueuedCommand, bs::StdAlloc<bs::QueuedCommand, bs::GenAlloc> > >*)> >::_M_invoke(std::_Any_data const&) of /usr/include/c++/8/bits/std_function.h:297
26 in std::function<void ()>::operator()() const of /usr/include/c++/8/bits/std_function.h:687
27 in bs::CommandQueueBase::playbackWithNotify(std::queue<bs::QueuedCommand, std::deque<bs::QueuedCommand, bs::StdAlloc<bs::QueuedCommand, bs::GenAlloc> > >*, std::function<void (unsigned int)>) of /home/hhyyrylainen/Projects/bsfExamples/bsf/Source/Foundation/bsfCore/CoreThread/BsCommandQueue.cpp:124
28 in bs::CoreThread::runCoreThread of /home/hhyyrylainen/Projects/bsfExamples/bsf/Source/Foundation/bsfCore/CoreThread/BsCoreThread.cpp:117
29 in std::__invoke_impl<void, void (bs::CoreThread::*&)(), bs::CoreThread*&> of /usr/include/c++/8/bits/invoke.h:73
30 in std::__invoke<void (bs::CoreThread::*&)(), bs::CoreThread*&> of /usr/include/c++/8/bits/invoke.h:95
31 in std::_Bind<void (bs::CoreThread::*(bs::CoreThread*))()>::__call<void, , 0ul>(std::tuple<>&&, std::_Index_tuple<0ul>) of /usr/include/c++/8/functional:400
32 in std::_Bind<void (bs::CoreThread::*(bs::CoreThread*))()>::operator()<, void>() of /usr/include/c++/8/functional:484
33 in std::_Function_handler<void (), std::_Bind<void (bs::CoreThread::*(bs::CoreThread*))()> >::_M_invoke(std::_Any_data const&) of /usr/include/c++/8/bits/std_function.h:297
34 in std::function<void ()>::operator()() const of /usr/include/c++/8/bits/std_function.h:687
35 in bs::PooledThread::run of /home/hhyyrylainen/Projects/bsfExamples/bsf/Source/Foundation/bsfUtility/Threading/BsThreadPool.cpp:122
36 in std::__invoke_impl<void, void (bs::PooledThread::*&)(), bs::PooledThread*&> of /usr/include/c++/8/bits/invoke.h:73
37 in std::__invoke<void (bs::PooledThread::*&)(), bs::PooledThread*&> of /usr/include/c++/8/bits/invoke.h:95
38 in std::_Bind<void (bs::PooledThread::*(bs::PooledThread*))()>::__call<void, , 0ul>(std::tuple<>&&, std::_Index_tuple<0ul>) of /usr/include/c++/8/functional:400
39 in std::_Bind<void (bs::PooledThread::*(bs::PooledThread*))()>::operator()<, void>() of /usr/include/c++/8/functional:484
40 in std::__invoke_impl<void, std::_Bind<void (bs::PooledThread::*(bs::PooledThread*))()>>(std::__invoke_other, std::_Bind<void (bs::PooledThread::*(bs::PooledThread*))()>&&) of /usr/include/c++/8/bits/invoke.h:60
41 in std::__invoke<std::_Bind<void (bs::PooledThread::*(bs::PooledThread*))()>>(std::_Bind<void (bs::PooledThread::*(bs::PooledThread*))()>&&) of /usr/include/c++/8/bits/invoke.h:95
42 in std::thread::_Invoker<std::tuple<std::_Bind<void (bs::PooledThread::*(bs::PooledThread*))()> > >::_M_invoke<0ul>(std::_Index_tuple<0ul>) of /usr/include/c++/8/thread:244
43 in std::thread::_Invoker<std::tuple<std::_Bind<void (bs::PooledThread::*(bs::PooledThread*))()> > >::operator()() of /usr/include/c++/8/thread:253
44 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<std::_Bind<void (bs::PooledThread::*(bs::PooledThread*))()> > > >::_M_run() of /usr/include/c++/8/thread:196
45 in ?? of /lib64/libstdc++.so.6
46 in start_thread of /lib64/libpthread.so.0
47 in clone of /lib64/libc.so.6

I couldn’t really pinpoint why that goes wrong. So I’m not sure if this is the same issue or not


#4

Thanks for the asset file. If you don’t mind opening an issue on this it would be great, I can’t look at this right away and might forget about it otherwise.


#5

Opened an issue: