Program segfaults on Ubuntu under simple or complex meshes
Makogan opened this issue · 2 comments
I am trying to generate some SDFs from OBJs using this tool. I have tried it with a watertight stanford dragon and the default blender cube. In both cases I get the following:
./bin/SDFGen cube.obj 5 2
Reading data.
Read in 8 vertices and 12 faces.
Bound box size: (-11 -11 -11) to (11 11 11) with dimensions 4 4 4.
Computing signed distance field.
Segmentation fault (core dumped)
When inspecting the code with gdb, it seems the segfault occurs in this function:
0x000055555555b229 in make_level_set3(std::vector<Vec<3u, unsigned int>, std::allocator<Vec<3u, unsigned int> > > const&, std::vector<Vec<3u, float>, std::allocator<Vec<3u, float> > > const&, Vec<3u, float> const&, float, int, int, int, Array3<float, Array1<float> >&, int) ()
There are no normals nor vertex coordinates in the input objs, and the documentaiton states that ./bin/SDFGen cube.obj 5 2
is the correct way to call the bindary.
I am a little confused and was hoping for a little guidance, thank you.
Update:
The problem seems to be an integer overflow, potentially cause by an implicit conversion from an unsigned int into an int.
In line 131 of makelevelset3.cpp
the values of q, r
reach really high values such as the binary representation of -1 as an unsigned integer.
faceList.push_back(Vec3ui(v0 - 1, v1 - 1, v2 - 1));This line of code may cause your vertex index value to be negative