You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: segmentation fault while removing redundant materials #5461
Describe the bug
While testing PR #5451 (the fix for issue #5438) I got a segmentation violation during post-processing. I reported this at #5438 on 1 February 2024, but since there's been no response (and the issue is closed and I don't have permission to re-open it) I'm filing a new issue.
Unzip the "Running.gltf" file from the following archive: test.zip
Execute the following command: bin/assimp info Running.gltf -rrm
Expected behavior
Since the test model is animation-only (contains no meshes) all its materials are redundant. Removing redundant materials should produce a model with no materials. The post-processor should not crash!
Screenshots
$ bin/assimp info ~/Downloads/Running.gltf -rrmparam = -rrmLaunching asset import ... OKValidating postprocessing flags ... OK100 %Importing file ... OK import took approx. 0.01244 secondsSegmentation fault (core dumped)
$ bin/assimp version------------------------------------------------------ Open Asset Import Library ("Assimp", https://github.com/assimp/assimp) -- Commandline toolchain -------------------------------------------------------- Version 5.3 -debug -shared -st (GIT commit ff5b0ae5)
$
Platform (please complete the following information):
OS: Linux Mint 21.3 (x86_64, 5.15 kernel)
Browser: Firefox
Version: Assimp built from GIT commit ff5b0ae (8 February 2024)
for (unsignedint i = 0; i < mScene->mNumMaterials;++i) {
Using GDB, I set a breakpoint at code/Common/Importer.cpp line 1268, and saw that mScene->mNumMaterials is 1. I believe it should've been set to zero in RemoveRedundantMatsProcess::Execute().
Stepping through RemoveRedundantMatsProcess::Execute(), I see it return from line 161:
At that point, mMaterials[0] has been set to nullptr, but mNumMaterials has not been updated---it is still 1. That explains the segmentation violation.
I could easily write a PR to solve this issue, but after what happened with #5438 I've decided to wait for an explicit PR request and not submit unsolicited code.
Activity
stephengold commentedon Feb 11, 2024
Address sanitizer output is available from #5438
stephengold commentedon Feb 11, 2024
Correction: the crash does not occur during post-processing. It occurs while calculating the scene's memory usage.
assimp/code/Common/Importer.cpp
Line 1268 in ff5b0ae
Using GDB, I set a breakpoint at code/Common/Importer.cpp line 1268, and saw that
mScene->mNumMaterialsis 1. I believe it should've been set to zero inRemoveRedundantMatsProcess::Execute().Stepping through
RemoveRedundantMatsProcess::Execute(), I see it return from line 161:assimp/code/PostProcessing/RemoveRedundantMaterials.cpp
Lines 159 to 162 in ff5b0ae
At that point,
mMaterials[0]has been set tonullptr, butmNumMaterialshas not been updated---it is still 1. That explains the segmentation violation.stephengold commentedon Feb 12, 2024
I could easily write a PR to solve this issue, but after what happened with #5438 I've decided to wait for an explicit PR request and not submit unsolicited code.
kimkulling commentedon Feb 17, 2024
Hi, would be great if you could prepare a PR for this issue.
Thanks!
fix issue #5461 (segfault after removing redundant materials) (#5467)
stephengold commentedon Apr 10, 2024
Since #5467 is integrated, I believe this issue is solved and can be closed.
fix issue #5461 (segfault after removing redundant materials) (#5467)