Pointer checking for Wrap

Issue #26 new
Alex Cunningham created an issue

One issue with the current wrap implementation is that it is possible to end up with an empty shared pointer somewhere, which there's no way to detect directly from matlab without causing a segfault.

It's really easy to do this with containers of shared pointers, like factor graphs, where the container might contain a null pointer, and if you try to pull out the factor, matlab will try to dereference the pointer and cause a segfault. There are also some functions that return a null shared_ptr on failure.

A reasonable solution would be to add a function to all of the wrapped objects that checks whether a pointer is live, so it is possible to do a safety check in matlab. The other part is to have all of the constructors check the pointer value and cause an exception that can be caught from within matlab instead of causing crashes. These would be updates to the generated code by wrap.

Comments (0)

  1. Log in to comment