Closed spevnev closed 4 months ago
Could you share example.gltf ?
It isn't any specific file. For instance, take gearbox_animation
from f3d-data
. In its gltf file you can see
"images": [
{
"uri": "textures/Material_26_metallicRoughness.png"
},
{
"uri": "textures/Material_26_normal.png"
},
{
"uri": "textures/Material_26_baseColor.png"
},
...
]
And if you remove any of these, or the entire folder, i.e. make uri no longer as files do not exist, it causes segfault. It probably doesn't check files before loading them.
I've attachied zips of 2 examples (couldn't upload as single file due to 25MB upload limit):
originals: for reference (both are taken from f3d-data
)
original_gearbox.zip
original_bristleback.zip
file_missing: deleted one texture file -> segfault
file_missing_gearbox.zip
file_missing_bristleback.zip
folder_missing: deleted all textures -> segfault
folder_missing_gearbox.zip
folder_missing_bristleback.zip
Thread 1 "f3d" received signal SIGSEGV, Segmentation fault.
0x00007ffff2ea3fcc in vtkGLTFDocumentLoader::LoadImageData (this=0x55555658e910) at /home/glow/dev/vtk/vtk1/src/IO/Geometry/vtkGLTFDocumentLoader.cxx:848
848 if (stream->Read(buffer.data(), buffer.size()) != buffer.size())
(gdb) bt
#0 0x00007ffff2ea3fcc in vtkGLTFDocumentLoader::LoadImageData (this=0x55555658e910) at /home/glow/dev/vtk/vtk1/src/IO/Geometry/vtkGLTFDocumentLoader.cxx:848
#1 0x00007ffff2ea55f8 in vtkGLTFDocumentLoader::LoadModelData (this=0x55555658e910, glbBuffer=std::vector of length 0, capacity 0)
at /home/glow/dev/vtk/vtk1/src/IO/Geometry/vtkGLTFDocumentLoader.cxx:976
#2 0x00007ffff375dd95 in vtkGLTFImporter::ImportBegin (this=0x555555cdf160) at /home/glow/dev/vtk/vtk1/src/IO/Import/vtkGLTFImporter.cxx:398
#3 0x00007ffff3775926 in vtkImporter::Read (this=0x555555cdf160) at /home/glow/dev/vtk/vtk1/src/IO/Import/vtkImporter.cxx:73
#4 0x00007ffff6070e78 in vtkImporter::Update (this=0x555555cdf160) at /home/glow/dev/vtk/vtk1/src/IO/Import/vtkImporter.h:92
#5 0x00007ffff60702bd in f3d::detail::loader_impl::loadScene (this=0x555555cce7b0, filePath="/home/glow/data/tmp/gearbox/scene.gltf")
at /home/glow/dev/f3d/f3d/src/library/src/loader_impl.cxx:318
#6 0x000055555566d979 in F3DStarter::LoadFile (this=0x7fffffffe5b8, index=0, relativeIndex=false) at /home/glow/dev/f3d/f3d/src/application/F3DStarter.cxx:810
#7 0x000055555566c399 in F3DStarter::Start (this=0x7fffffffe5b8, argc=2, argv=0x7fffffffe718) at /home/glow/dev/f3d/f3d/src/application/F3DStarter.cxx:576
#8 0x000055555567ac1e in main (argc=2, argv=0x7fffffffe718) at /home/glow/dev/f3d/f3d/src/application/main.cxx:13
(gdb)
Complete fix will require to work on the importer API: https://github.com/f3d-app/f3d/issues/653
Fixed in VTK thanks for https://gitlab.kitware.com/vtk/vtk/-/merge_requests/11267
Need a bit more work to integrate in F3D
Describe the bug gltf files contain list of images/textures and when it is opened without these images in the path f3d segfaults. It probably happens with other file formats, but I haven't tested them. Here's the stack trace:
To Reproduce Steps to reproduce the behavior:
f3d example.gltf
Expected behavior Either generic error message like "Error opening gltf file" or better yet "Error loading texture TEXTURE_PATH required by GLTF_PATH: file doesn't exist"
System Information:
F3D Information Paste the content of
f3d --version
:Additional context It happens in libvtk which (if I understand correctly) is a dependency, so to fix we need to read these texture paths (are they already read/available somewhere?) from the gltf file and check that they exist before calling libvtk functions.