vtkOBJImporter segfault with a specific file
Describe the bug Reading an obj with the vtkOBJImporter can segfault with a specific file
To Reproduce Steps to reproduce the behavior: 0. spider.zip
- Build https://kitware.github.io/vtk-examples/site/Cxx/IO/OBJImporter/
./OBJImporter path/to/spider.obj path/to/spider.mtl path/to
- segfault
Program received signal SIGSEGV, Segmentation fault.
(anonymous namespace)::tokenGetTexture (t=@0x7ffffffe4e60: 181, tokens=std::vector of length 184, capacity 256 = {...}, current_mtl=0x5555557108f0, texturePath="/home/glow/aur/assimp/src/assimp-5.2.1/test/models/OBJ/") at /home/glow/dev/vtk/vtk1/src/IO/Import/vtkOBJImporterInternals.cxx:235
235 while (tokens[tt].Type != Token::LineEnd)
(gdb) bt
#0 (anonymous namespace)::tokenGetTexture (t=@0x7ffffffe4e60: 181, tokens=std::vector of length 184, capacity 256 = {...}, current_mtl=0x5555557108f0,
texturePath="/home/glow/aur/assimp/src/assimp-5.2.1/test/models/OBJ/") at /home/glow/dev/vtk/vtk1/src/IO/Import/vtkOBJImporterInternals.cxx:235
#1 0x00007ffff5623385 in vtkOBJPolyDataProcessor::ParseOBJandMTL (this=0x5555556e7d80,
Filename="/home/glow/aur/assimp/src/assimp-5.2.1/test/models/OBJ/spider.mtl", result_code=@0x7ffffffe5188: 0)
at /home/glow/dev/vtk/vtk1/src/IO/Import/vtkOBJImporterInternals.cxx:351
#2 0x00007ffff560e66f in vtkOBJPolyDataProcessor::RequestData (this=0x5555556e7d80) at /home/glow/dev/vtk/vtk1/src/IO/Import/vtkOBJImporter.cxx:400
#3 0x00007ffff26d0f08 in vtkPolyDataAlgorithm::ProcessRequest (this=0x5555556e7d80, request=0x555555f73170, inputVector=0x0, outputVector=0x555555f687e0)
at /home/glow/dev/vtk/vtk1/src/Common/ExecutionModel/vtkPolyDataAlgorithm.cxx:88
#4 0x00007ffff26a5cbb in vtkExecutive::CallAlgorithm (this=0x555555ab8bc0, request=0x555555f73170, direction=1, inInfo=0x0, outInfo=0x555555f687e0)
at /home/glow/dev/vtk/vtk1/src/Common/ExecutionModel/vtkExecutive.cxx:735
#5 0x00007ffff269c048 in vtkDemandDrivenPipeline::ExecuteData (this=0x555555ab8bc0, request=0x555555f73170, inInfo=0x0, outInfo=0x555555f687e0)
at /home/glow/dev/vtk/vtk1/src/Common/ExecutionModel/vtkDemandDrivenPipeline.cxx:462
#6 0x00007ffff268f281 in vtkCompositeDataPipeline::ExecuteData (this=0x555555ab8bc0, request=0x555555f73170, inInfoVec=0x0, outInfoVec=0x555555f687e0)
at /home/glow/dev/vtk/vtk1/src/Common/ExecutionModel/vtkCompositeDataPipeline.cxx:163
#7 0x00007ffff269b5f5 in vtkDemandDrivenPipeline::ProcessRequest (this=0x555555ab8bc0, request=0x555555f73170, inInfoVec=0x0, outInfoVec=0x555555f687e0)
at /home/glow/dev/vtk/vtk1/src/Common/ExecutionModel/vtkDemandDrivenPipeline.cxx:261
#8 0x00007ffff2767534 in vtkStreamingDemandDrivenPipeline::ProcessRequest (this=0x555555ab8bc0, request=0x555555f73170, inInfoVec=0x0,
outInfoVec=0x555555f687e0) at /home/glow/dev/vtk/vtk1/src/Common/ExecutionModel/vtkStreamingDemandDrivenPipeline.cxx:344
#9 0x00007ffff269be2d in vtkDemandDrivenPipeline::UpdateData (this=0x555555ab8bc0, outputPort=0)
at /home/glow/dev/vtk/vtk1/src/Common/ExecutionModel/vtkDemandDrivenPipeline.cxx:419
#10 0x00007ffff27678c4 in vtkStreamingDemandDrivenPipeline::Update (this=0x555555ab8bc0, port=0, requests=0x0)
at /home/glow/dev/vtk/vtk1/src/Common/ExecutionModel/vtkStreamingDemandDrivenPipeline.cxx:418
#11 0x00007ffff276774d in vtkStreamingDemandDrivenPipeline::Update (this=0x555555ab8bc0, port=0)
at /home/glow/dev/vtk/vtk1/src/Common/ExecutionModel/vtkStreamingDemandDrivenPipeline.cxx:381
#12 0x00007ffff268438a in vtkAlgorithm::Update (this=0x5555556e7d80, port=0) at /home/glow/dev/vtk/vtk1/src/Common/ExecutionModel/vtkAlgorithm.cxx:1492
#13 0x00007ffff2684355 in vtkAlgorithm::Update (this=0x5555556e7d80) at /home/glow/dev/vtk/vtk1/src/Common/ExecutionModel/vtkAlgorithm.cxx:1486
#14 0x00007ffff560cc04 in vtkOBJImporter::ReadData (this=0x555555f68a30) at /home/glow/dev/vtk/vtk1/src/IO/Import/vtkOBJImporter.cxx:87
#15 0x00007ffff55faacb in vtkImporter::Read (this=0x555555f68a30) at /home/glow/dev/vtk/vtk1/src/IO/Import/vtkImporter.cxx:87
#16 0x00007ffff7ea2a22 in vtkImporter::Update (this=0x555555f68a30) at /home/glow/dev/vtk/vtk1/src/IO/Import/vtkImporter.h:92
#17 0x00007ffff7ea2543 in f3d::detail::loader_impl::loadFile (this=0x555555712540, load=f3d::loader::LoadFileEnum::LOAD_CURRENT)
at /home/glow/dev/f3d/f3d/src/library/src/loader_impl.cxx:379
#18 0x0000555555617d8d in F3DStarter::LoadFile (this=0x7fffffffe720, load=f3d::loader::LoadFileEnum::LOAD_CURRENT)
at /home/glow/dev/f3d/f3d/src/application/F3DStarter.cxx:357
#19 0x0000555555617038 in F3DStarter::Start (this=0x7fffffffe720, argc=2, argv=0x7fffffffe868) at /home/glow/dev/f3d/f3d/src/application/F3DStarter.cxx:202
#20 0x000055555561b4e9 in main (argc=2, argv=0x7fffffffe868) at /home/glow/dev/f3d/f3d/src/application/main.cxx:13
Additional context
- Easy to fix in the file, just add a new line at the end. But still, this should be fixed
- Once fixed, texture do not load because of
\
in the file, this is also an issue as obj can contain windows path - vtkOBJReader reeads the file fine (tested with ParaView)