Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in fg::Parser::generateMeshIndices(): accessor.count assignment uses invalid positionAccessor reference #55

Closed
droettger opened this issue Mar 8, 2024 · 1 comment
Labels
bug Something isn't working done Everything has been addressed

Comments

@droettger
Copy link

Error in fg::Parser::generateMeshIndices() when assigning accessor.count from dead positionAccessor.count data.
Results in "bad allcoation" error when trying to allocate the given huge accessor.count data later.
Repro:
MSVS 2022 Debug 64 build.
Load the file https://github.com/KhronosGroup/glTF-Sample-Models/blob/main/2.0/TriangleWithoutIndices/glTF/TriangleWithoutIndices.gltf
with fastgltf::Options::GenerateMeshIndices enabled.
I used these settings

  constexpr auto gltfOptions = fastgltf::Options::None 
    | fastgltf::Options::DontRequireValidAssetMember
    | fastgltf::Options::LoadGLBBuffers
    | fastgltf::Options::LoadExternalBuffers
    | fastgltf::Options::LoadExternalImages
    | fastgltf::Options::GenerateMeshIndices;

BUG: The fg::Parser::generateMeshIndices() function assignment accessor.count = positionAccessor.count; in line 895 is using stale data because the auto& accessor = asset.accessors.emplace_back(); changed the accessor vector and invalidates the previously read positionAccessor reference. In debug mode, all positionAccessor data becomes 0xdddddddd, which is a huge count and results in an allocation error when used later.

@spnda spnda added the bug Something isn't working label Mar 8, 2024
@spnda spnda closed this as completed in ce73158 Mar 8, 2024
@spnda spnda added the done Everything has been addressed label Mar 8, 2024
@droettger
Copy link
Author

Wow, that was quick. Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working done Everything has been addressed
Projects
None yet
Development

No branches or pull requests

2 participants