Skip to content

Bug: segmentation fault while removing redundant materials #5461

Closed

Description

@stephengold

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.

To Reproduce
Steps to reproduce the behavior:

  1. Build the assimp command from source code recent enough to include PR Kimkulling/fix bahavior of remove redundat mats issue 5438 #5451.

  2. Unzip the "Running.gltf" file from the following archive:
    test.zip

  3. 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 -rrm
param = -rrm
Launching asset import ...           OK
Validating postprocessing flags ...  OK
100 %Importing file ...                   OK 
   import took approx. 0.01244 seconds

Segmentation 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)

Additional context
N/A

Activity

  1. added
    Bug
    on Feb 11, 2024
  2. stephengold commented on Feb 11, 2024

    @stephengold
    ContributorAuthor

    Address sanitizer output is available from #5438

  3. stephengold commented on Feb 11, 2024

    @stephengold
    ContributorAuthor

    Correction: the crash does not occur during post-processing. It occurs while calculating the scene's memory usage.

    for (unsigned int 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:

    if (iNewNum < 1) {
    //throw DeadlyImportError("No materials remaining");
    return;
    }

    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.

  4. stephengold commented on Feb 12, 2024

    @stephengold
    ContributorAuthor

    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.

  5. kimkulling commented on Feb 17, 2024

    @kimkulling
    Member

    Hi, would be great if you could prepare a PR for this issue.

    Thanks!

  6. added a commit that references this issue on Apr 9, 2024
  7. stephengold commented on Apr 10, 2024

    @stephengold
    ContributorAuthor

    Since #5467 is integrated, I believe this issue is solved and can be closed.

  8. added
    Materials
    Crash
    on Apr 24, 2026
  9. added a commit that references this issue on Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugCrashMaterials

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions