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

gltfio: crash when loading invalid content #7868

Closed
mcooley opened this issue May 17, 2024 · 0 comments · Fixed by #7885
Closed

gltfio: crash when loading invalid content #7868

mcooley opened this issue May 17, 2024 · 0 comments · Fixed by #7885
Assignees
Labels
bug Something isn't working gltf Specific to glTF support

Comments

@mcooley
Copy link

mcooley commented May 17, 2024

Describe the bug
createAsset crashes when given content that's valid JSON, but invalid GLTF.

To Reproduce

Engine* engine = Engine::create();
MaterialProvider* materialProvider = createUbershaderProvider(engine, UBERARCHIVE_DEFAULT_DATA, UBERARCHIVE_DEFAULT_SIZE);
ResourceLoader* resourceLoader = new ResourceLoader(ResourceConfiguration{ .engine = engine });
AssetLoader* assetLoader = AssetLoader::create({ engine, materialProvider });

std::string validJsonInvalidGLTF = "{ \"invalid\": \"gltf\" }";
FilamentAsset* asset = assetLoader->createAsset(reinterpret_cast<uint8_t*>(validJsonInvalidGLTF.data()), validJsonInvalidGLTF.size());

With Filament 1.51.8, this program logs "There is no scene in the asset." to console, and then hits an access violation.

Expected behavior
Print an error to console, and createAsset should return nullptr without crashing.

Logs
Call stack:

filament_test.exe!std::copy_n<filament::gltfio::FFilamentInstance * *,unsigned __int64,filament::gltfio::FilamentInstance * *>(filament::gltfio::FFilamentInstance * * _First, unsigned __int64 _Count_raw, filament::gltfio::FilamentInstance * * _Dest) Line 4217	C++
filament_test.exe!filament::gltfio::FAssetLoader::createInstancedAsset(const unsigned char * bytes, unsigned int byteCount, filament::gltfio::FilamentInstance * * instances, unsigned __int64 numInstances) Line 369	C++
filament_test.exe!filament::gltfio::FAssetLoader::createAsset(const unsigned char * bytes, unsigned int byteCount) Line 315	C++
filament_test.exe!filament::gltfio::AssetLoader::createAsset(const unsigned char * bytes, unsigned int nbytes) Line 1617	C++
filament_test.exe!main(int argc, char * * argv) Line 22	C++

Desktop (please complete the following information):

  • OS: Windows 11
  • GPU: Intel Iris Xe
  • Backend: Vulkan
@pixelflinger pixelflinger added bug Something isn't working gltf Specific to glTF support labels May 21, 2024
poweifeng added a commit that referenced this issue May 24, 2024
Invalid gltf but valid json should not crash but
return null for asset.

Fixes #7868
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working gltf Specific to glTF support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants