f3d icon indicating copy to clipboard operation
f3d copied to clipboard

GLTF related segfaults

Open mwestphal opened this issue 2 years ago • 6 comments

Describe the bug Multiple specific GLTF files causes segfaults of F3D.

Segfaults
f3d: /home/glow/dev/vtk/vtk1/src/ThirdParty/nlohmannjson/vtknlohmannjson/include/vtknlohmann/json.hpp:3928: const vtknlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::value_type& vtknlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::operator[](T*) const [with T = const char; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = vtknlohmann::adl_serializer; BinaryType = std::vector<unsigned char>; const_reference = const vtknlohmann::basic_json<>&]: Assertion `m_value.object->find(key) != m_value.object->end()' failed.

Program received signal SIGABRT, Aborted.
0x00007ffff78c164c in ?? () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff78c164c in ?? () from /usr/lib/libc.so.6
#1  0x00007ffff7871938 in raise () from /usr/lib/libc.so.6
#2  0x00007ffff785b53d in abort () from /usr/lib/libc.so.6
#3  0x00007ffff785b45c in ?? () from /usr/lib/libc.so.6
#4  0x00007ffff786a486 in __assert_fail () from /usr/lib/libc.so.6
#5  0x00007ffff54d6ff2 in vtknlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, vtknlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >::operator[]<char const>
    (this=0x5555560453b0, key=0x7ffff551f9cd "attributes")
    at /home/glow/dev/vtk/vtk1/src/ThirdParty/nlohmannjson/vtknlohmannjson/include/vtknlohmann/json.hpp:3928
#6  0x00007ffff54cd00b in vtkGLTFDocumentLoaderInternals::LoadPrimitive (this=0x7fffffffdf80, root=..., primitive=...)
    at /home/glow/dev/vtk/vtk1/src/IO/Geometry/vtkGLTFDocumentLoaderInternals.cxx:1065
#7  0x00007ffff54ca516 in vtkGLTFDocumentLoaderInternals::LoadMesh (this=0x7fffffffdf80, root=..., mesh=...)
    at /home/glow/dev/vtk/vtk1/src/IO/Geometry/vtkGLTFDocumentLoaderInternals.cxx:783
#8  0x00007ffff54d1f79 in vtkGLTFDocumentLoaderInternals::LoadModelMetaDataFromFile (this=0x7fffffffdf80, 
    fileName="/home/glow/aur/assimp/src/assimp-5.2.1/test/models/glTF2/wrongTypes/badArray.gltf", extensionsUsedByLoader=std::vector of length 0, capacity 0)
    at /home/glow/dev/vtk/vtk1/src/IO/Geometry/vtkGLTFDocumentLoaderInternals.cxx:1403
#9  0x00007ffff533efae in vtkGLTFDocumentLoader::LoadModelMetaDataFromFile (this=0x5555560427e0, 
    fileName="/home/glow/aur/assimp/src/assimp-5.2.1/test/models/glTF2/wrongTypes/badArray.gltf")
    at /home/glow/dev/vtk/vtk1/src/IO/Geometry/vtkGLTFDocumentLoader.cxx:177
#10 0x00007ffff55e455a in vtkGLTFImporter::ImportBegin (this=0x55555570cf10) at /home/glow/dev/vtk/vtk1/src/IO/Import/vtkGLTFImporter.cxx:397
#11 0x00007ffff55faa9f in vtkImporter::Read (this=0x55555570cf10) at /home/glow/dev/vtk/vtk1/src/IO/Import/vtkImporter.cxx:85
#12 0x00007ffff7ea2a22 in vtkImporter::Update (this=0x55555570cf10) at /home/glow/dev/vtk/vtk1/src/IO/Import/vtkImporter.h:92
#13 0x00007ffff7ea2543 in f3d::detail::loader_impl::loadFile (this=0x555555706050, load=f3d::loader::LoadFileEnum::LOAD_CURRENT)
    at /home/glow/dev/f3d/f3d/src/library/src/loader_impl.cxx:379
#14 0x0000555555617d8d in F3DStarter::LoadFile (this=0x7fffffffe700, load=f3d::loader::LoadFileEnum::LOAD_CURRENT)
    at /home/glow/dev/f3d/f3d/src/application/F3DStarter.cxx:357
#15 0x0000555555617038 in F3DStarter::Start (this=0x7fffffffe700, argc=3, argv=0x7fffffffe848) at /home/glow/dev/f3d/f3d/src/application/F3DStarter.cxx:202
#16 0x000055555561b4e9 in main (argc=3, argv=0x7fffffffe848) at /home/glow/dev/f3d/f3d/src/application/main.cxx:13

Segfaults
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

Program received signal SIGABRT, Aborted.
0x00007ffff789f26c in ?? () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff789f26c in ?? () from /usr/lib/libc.so.6
#1  0x00007ffff784fa08 in raise () from /usr/lib/libc.so.6
#2  0x00007ffff7838538 in abort () from /usr/lib/libc.so.6
#3  0x00007ffff7a9ca6f in __gnu_cxx::__verbose_terminate_handler () at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/vterminate.cc:95
#4  0x00007ffff7ab011c in __cxxabiv1::__terminate (handler=<optimized out>) at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:48
#5  0x00007ffff7ab0189 in std::terminate () at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:58
#6  0x00007ffff7ab03ed in __cxxabiv1::__cxa_throw (obj=<optimized out>, tinfo=0x7ffff7c6ab28 <typeinfo for std::bad_alloc>, dest=0x7ffff7aae680 <std::bad_alloc::~bad_alloc()>)
    at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/eh_throw.cc:98
#7  0x00007ffff7a9c4f3 in operator new (sz=3348087199840816) at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/new_op.cc:54
#8  0x00007ffff589a0e6 in std::__new_allocator<double>::allocate (this=0x7fffffffd5d8, __n=418510899980102) at /usr/include/c++/13.1.1/bits/new_allocator.h:147
#9  0x00007ffff58975fb in std::allocator_traits<std::allocator<double> >::allocate (__n=418510899980102, __a=...) at /usr/include/c++/13.1.1/bits/alloc_traits.h:482
#10 std::_Vector_base<double, std::allocator<double> >::_M_allocate (this=0x7fffffffd5d8, __n=418510899980102) at /usr/include/c++/13.1.1/bits/stl_vector.h:378
#11 0x00007ffff58b84bd in std::_Vector_base<double, std::allocator<double> >::_M_create_storage (this=0x7fffffffd5d8, __n=418510899980102) at /usr/include/c++/13.1.1/bits/stl_vector.h:395
#12 0x00007ffff58b3919 in std::_Vector_base<double, std::allocator<double> >::_Vector_base (this=0x7fffffffd5d8, __n=418510899980102, __a=...) at /usr/include/c++/13.1.1/bits/stl_vector.h:332
#13 0x00007ffff58afa5b in std::vector<double, std::allocator<double> >::vector (this=0x7fffffffd5d8, __x=std::vector of length 418510899980102, capacity -614433100367020602 = {...})
    at /usr/include/c++/13.1.1/bits/stl_vector.h:600
#14 0x00007ffff58ae910 in vtkGLTFDocumentLoader::Accessor::Accessor (this=0x7fffffffd5c0) at /home/glow/dev/vtk/vtk1/src/IO/Geometry/vtkGLTFDocumentLoader.h:134
#15 0x00007ffff58a37c3 in vtkGLTFDocumentLoader::ExtractPrimitiveAccessorData (this=0x555555fbf6d0, primitive=...) at /home/glow/dev/vtk/vtk1/src/IO/Geometry/vtkGLTFDocumentLoader.cxx:583
#16 0x00007ffff58a7511 in vtkGLTFDocumentLoader::LoadModelData (this=0x555555fbf6d0, glbBuffer=std::vector of length 379432, capacity 379432 = {...})
    at /home/glow/dev/vtk/vtk1/src/IO/Geometry/vtkGLTFDocumentLoader.cxx:933
#17 0x00007ffff5c8299b in vtkGLTFImporter::ImportBegin (this=0x555555674a20) at /home/glow/dev/vtk/vtk1/src/IO/Import/vtkGLTFImporter.cxx:402
#18 0x00007ffff5c9896d in vtkImporter::Read (this=0x555555674a20) at /home/glow/dev/vtk/vtk1/src/IO/Import/vtkImporter.cxx:85
#19 0x00007ffff7f25217 in f3d::detail::loader_impl::loadScene(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
   from /home/glow/dev/f3d/f3d/build/lib/libf3d.so.2
#20 0x00005555555c518f in F3DStarter::LoadFile(int, bool) ()
#21 0x00005555555c8900 in F3DStarter::Start(int, char**) ()
#22 0x0000555555570595 in main ()

mwestphal avatar Feb 05 '23 14:02 mwestphal

FYI @Meakk , all of this concerns "invalid" files but we should not crash anyway.

mwestphal avatar Feb 05 '23 14:02 mwestphal

Sister VTK issue: https://gitlab.kitware.com/vtk/vtk/-/issues/18809

mwestphal avatar Feb 06 '23 07:02 mwestphal

Added a few:

  • BoxTextured.glb
  • NoScene.gltf
  • RecursiveNodes.gltf
  • SceneWithoutNodes.gltf
  • sceneWrongType.gltf

mwestphal avatar Jul 09 '23 10:07 mwestphal

Removed many that have been fixed thanks to improvements in VTK

mwestphal avatar Dec 05 '23 10:12 mwestphal

Added capoeira1.gltf

mwestphal avatar Dec 05 '23 10:12 mwestphal

removed the ones that were fixed recently

mwestphal avatar Jul 09 '24 07:07 mwestphal