f3d: F3D segfault with a specific FBX file

Describe the bug F3D segfault with a specific FBX file: https://sketchfab.com/3d-models/wolf-e319f122c2474d3186b841b019fb0edd

wolf.zip

To Reproduce Steps to reproduce the behavior:

  1. Open the file using ./bin/f3d ~/data/tmp/source/Wolf_test_animation_.fbx
  2. segfault

Expected behavior No segfault

System Information:

  • OS: ArchLinux
  • GPU and GPU driver: Unrelevant

F3D Information Paste the content of f3d --version:

F3D 2.4.0

F3D - A fast and minimalist 3D viewer
Version: 2.4.0-87-gbb439bdb.
Build date: 2024-06-28 06:54:00.
Build system: Linux 64-bits.
Compiler: GNU 14.1.1.
External rendering module: OFF.
Raytracing module: OFF.
VTK version: 9.3.0-3549-g2e9a7c71a2 (date: 20240627).
Copyright (C) 2019-2021 Kitware SAS.
Copyright (C) 2021-2024 Michael Migliore, Mathieu Westphal.
License BSD-3-Clause.
By Michael Migliore, Mathieu Westphal and Joachim Pouderoux.

Additional context

Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7fffe6bff6c0 (LWP 103344)]
Configuration file for "config" could not be found

Thread 1 "f3d" received signal SIGSEGV, Segmentation fault.
0x00007ffff2de466b in Assimp::LimitBoneWeightsProcess::ProcessMesh(aiMesh*) () from /home/glow/dev/f3d/deps/assimp/install/lib/libassimp.so.5
(gdb) bt
#0  0x00007ffff2de466b in Assimp::LimitBoneWeightsProcess::ProcessMesh(aiMesh*) () from /home/glow/dev/f3d/deps/assimp/install/lib/libassimp.so.5
#1  0x00007ffff2de3ff4 in Assimp::LimitBoneWeightsProcess::Execute(aiScene*) () from /home/glow/dev/f3d/deps/assimp/install/lib/libassimp.so.5
#2  0x00007ffff2d583e2 in Assimp::BaseProcess::ExecuteOnScene(Assimp::Importer*) () from /home/glow/dev/f3d/deps/assimp/install/lib/libassimp.so.5
#3  0x00007ffff2d677b3 in Assimp::Importer::ApplyPostProcessing(unsigned int) () from /home/glow/dev/f3d/deps/assimp/install/lib/libassimp.so.5
#4  0x00007ffff2d66e53 in Assimp::Importer::ReadFile(char const*, unsigned int) () from /home/glow/dev/f3d/deps/assimp/install/lib/libassimp.so.5
#5  0x00007ffff616a3fc in Assimp::Importer::ReadFile (this=0x555556582fe0, pFile="/home/glow/data/tmp/source/Wolf_test_animation_.fbx", pFlags=512)
    at /home/glow/dev/f3d/deps/assimp/install/include/assimp/Importer.hpp:668
#6  0x00007ffff616eb53 in vtkF3DAssimpImporter::vtkInternals::ReadScene (this=0x555556582fe0, filePath="/home/glow/data/tmp/source/Wolf_test_animation_.fbx")
    at /home/glow/dev/f3d/f3d/src/plugins/assimp/module/vtkF3DAssimpImporter.cxx:601
#7  0x00007ffff61677b0 in vtkF3DAssimpImporter::ImportBegin (this=0x555556586990) at /home/glow/dev/f3d/f3d/src/plugins/assimp/module/vtkF3DAssimpImporter.cxx:898
#8  0x00007ffff267b926 in vtkImporter::Read (this=0x555556586990) at /home/glow/dev/vtk/vtk1/src/IO/Import/vtkImporter.cxx:73
#9  0x00007ffff609e81e in vtkImporter::Update (this=0x555556586990) at /home/glow/dev/vtk/vtk1/src/IO/Import/vtkImporter.h:92
#10 0x00007ffff609dc63 in f3d::detail::loader_impl::loadScene (this=0x555555ce3200, filePath="/home/glow/data/tmp/source/Wolf_test_animation_.fbx")
    at /home/glow/dev/f3d/f3d/src/library/src/loader_impl.cxx:318
#11 0x000055555568043a in F3DStarter::LoadFile (this=0x7fffffffe598, index=0, relativeIndex=false) at /home/glow/dev/f3d/f3d/src/application/F3DStarter.cxx:814
#12 0x000055555567ee09 in F3DStarter::Start (this=0x7fffffffe598, argc=2, argv=0x7fffffffe6f8) at /home/glow/dev/f3d/f3d/src/application/F3DStarter.cxx:574
#13 0x000055555568d786 in main (argc=2, argv=0x7fffffffe6f8) at /home/glow/dev/f3d/f3d/src/application/main.cxx:13

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (18 by maintainers)

Most upvoted comments

#2051 was created. I didn’t find how to add reviewers myself @Meakk

Yes, only maintainers can addd reviewrers 😃

I checked how it is done in assimp_view and in Assimp::Importer::ReadFile validation of data structure (preventing furtaher steps) before post processing(where crash can happen) in assimp/code/Common/Importer.cpp:731 if flag aiProcess_ValidateDataStructure is set, which is done in assimp_view but not in f3d.

So I guess safer choice in f3d is to call assimp in this way in f3d/plugins/assimp/module/vtkF3DAssimpImporter.cxx:594, setting this flag:

this->Scene = this->Importer.ReadFile(filePath, aiProcess_LimitBoneWeights|aiProcess_ValidateDataStructure);

I can prepare commit for f3d to add it, as it is safer way to call assimp. Probably same name for the bone is ok for fbx files and assimp just doesn’t support it fully, but at least it gives error about file. Also it could also give an error about other kind of problems with fbx for assimp preventing unexpected behavior.

That looks ok but its for @Meakk to confirm the approach. Please open a PR 😃

ok, well in any case, fixing the crash is always good, once it is fixed, we can just open an issue on assimp repo to report that the file is not opening correctly. There are dozen of issue with FBX format in assimp.

Its better than a segfault at least.

Yes the fix is likely in the assimp code.

I am working on this issue. There is a buffer overflow in assimp code, but I am not exactly sure what should be exactly the correct handling of it yet, probably will ask assimp developers. I doubled the size of buffer allocation so crash is not happening but result doesn’t look exactly like a healthy wolf I would say 😃 Anyway I will continue on this issue

Image