RenderKit / ospray

An Open, Scalable, Portable, Ray Tracing Based Rendering Engine for High-Fidelity Visualization
http://ospray.org
Apache License 2.0
1k stars 182 forks source link

Segfault on committing group with "empty" isosurface geometry #356

Closed paulmelis closed 4 years ago

paulmelis commented 5 years ago

In the (reduced) test case below I'm setting up an isosurface geometry with the intent of later on linking up the actual volume and setting isosurface values to use. The commit on group triggers a segfault, in what looks to be the geometry generation of the isosurface at the Embree level. This is with the devel branch, btw

When I add a ospCommit(geometry) directly after the ospNewGeometry no segfault occurs at that point, it sill happens at the commit of group. So I assume it is allowed to commit an "underspecified" isosurface geometry and not have it do anything until enough parameters are set and then commit once that point is reached.

$ cat t_empty_geometry_segfault.c 
#include "ospray/ospray.h"

int 
main(int argc, const char **argv) 
{
    OSPError init_error = ospInit(&argc, argv);
    if (init_error != OSP_NO_ERROR)
        return init_error;

    OSPGeometry geometry = ospNewGeometry("isosurfaces"); 
    OSPGeometricModel gmodel = ospNewGeometricModel(geometry);
    OSPData data = ospNewData(1, OSP_OBJECT, &gmodel, 0);
    OSPGroup group = ospNewGroup();
    ospSetObject(group, "geometry", data);
    ospCommit(group);
}

$ gcc -g -o t_empty_geometry_segfault -I $HOME/software/ospray-superbuild-git/ospray/include/ t_empty_geometry_segfault.c -L $HOME/software/ospray-superbuild-git/ospray/lib64/ -lospray

$ gdb ./t_empty_geometry_segfault
GNU gdb (GDB) 8.3
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./t_empty_geometry_segfault...
(gdb) run
Starting program: /home/melis/concepts/blender-ospray-engine/tests/t_empty_geometry_segfault 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7058176 in ospray::Isosurfaces::createEmbreeGeometry() () from /home/melis/software/ospray-superbuild-git/ospray/lib64/libospray_module_ispc.so
(gdb) bt
#0  0x00007ffff7058176 in ospray::Isosurfaces::createEmbreeGeometry() () from /home/melis/software/ospray-superbuild-git/ospray/lib64/libospray_module_ispc.so
#1  0x00007ffff70348fc in ospray::Group::commit() () from /home/melis/software/ospray-superbuild-git/ospray/lib64/libospray_module_ispc.so
#2  0x00007ffff7faa00f in ospCommit () from /home/melis/software/ospray-superbuild-git/ospray/lib64/libospray.so.1
#3  0x0000555555555258 in main (argc=1, argv=0x7fffffffe348) at t_empty_geometry_segfault.c:15
jeffamstutz commented 4 years ago

This really should be a error that Isosurfaces::commit() doesn't throw. I'll get this fix into release-2.0.x ASAP...thanks!

jeffamstutz commented 4 years ago

This now throws an error on commit of the isosurface geometry in c93f87e7.