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

Segfault when reading gltf using EXT_meshopt_compression / ... #927

Open
paulmelis opened this issue Mar 27, 2024 · 1 comment
Open

Segfault when reading gltf using EXT_meshopt_compression / ... #927

paulmelis opened this issue Mar 27, 2024 · 1 comment
Milestone

Comments

@paulmelis
Copy link
Contributor

paulmelis commented Mar 27, 2024

Description

This is with a .glb as output by gltfpack, which uses a few extensions:

melis@blackbox 12:56:~/c/StereoKit-develop$ ~/concepts/glbdump/glbdump model.glb
Total file size 2,189,208 bytes

JSON chunk (22,640 bytes)

Asset Version   : 2.0
      Generator : "gltfpack 0.20"

Extensions (used)     : KHR_mesh_quantization, EXT_meshopt_compression, KHR_texture_transform
           (required) : KHR_mesh_quantization, EXT_meshopt_compression

It's okay if SK refuses to read anything that it can't handle in terms of glTF extensions, but since I'm getting a segfault (below) I assume there's something wrong in the decoding of (probably) the EXT_meshopt_compression data. Or perhaps the quantization used. Interestingly, cgltf does not list support for KHR_mesh_quantization in its readme, but does appear to actually support it.

Edit: just tested with a file using only KHR_mesh_quantization and KHR_texture_transform (same input file, no -c option to gltfpack) and that loads without problems.

Platform / Environment

Linux, SK repo (ea5e48d)

Logs or exception details

#include <stdio.h>
#include "stereokit.h"

using namespace sk;

int main()
{
    sk_settings_t settings = {};
    settings.app_name      = "StereoKit C";
    settings.assets_folder = "Assets";
    settings.mode          = app_mode_xr;

    if (!sk_init(settings))
	return 1;    
    
    model_t m = model_create_file("model.glb");
    
    sk_shutdown();
}

Appears to be a null pointer:

[SK diagnostic] Initializing World
[SK diagnostic] Initializing Physics
[SK diagnostic] Initializing Input
[SK info] Initialization successful

Thread 1 "StereoKit Main" received signal SIGSEGV, Segmentation fault.
0x00007ffff7e42fc0 in sk::gltf_parsemesh (mesh=<optimized out>, warnings=<optimized out>, filename=<optimized out>, primitive_id=<optimized out>, node_id=<optimized out>)
    at /home/melis/c/StereoKit-develop/StereoKitC/asset_types/model_gltf.cpp:406
406					inds[v] = *ind;
(gdb) p v
$1 = <optimized out>
(gdb) p ind
$2 = (uint16_t *) 0x0

model.glb.gz

@maluoi
Copy link
Collaborator

maluoi commented Mar 27, 2024

Ay okay, that's not great, yeah! I can definitely reproduce that with your model.

I do have some work related to this in the feature/gltf_meshopt branch. I believe I had a number of models from gltfpack working, but it looks like it doesn't work on yours. Doesn't crash, but doesn't load it right yet.

@maluoi maluoi added this to the v0.3.10 milestone Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review
Development

No branches or pull requests

2 participants