Is your feature request related to a problem? Please describe.
libf3d recently added C bindings, however exception handling was skipped.
Triggering an exception from the C binding is completely non-descriptive and cannot be handled properly from the C code, the C binding should handle exceptions instead.
[arch:61570:0:61570] Caught signal 11 (Segmentation fault: Sent by the kernel at address (nil))
Thread 1 "f3d_c_api_tests" received signal SIGSEGV, Segmentation fault.
x86_64_fallback_frame_state (context=0x7fffffffdf50, fs=0x7fffffffe040) at ./md-unwind-support.h:57
warning: 57 ./md-unwind-support.h: No such file or directory
(gdb) bt
#0 x86_64_fallback_frame_state (context=0x7fffffffdf50, fs=0x7fffffffe040) at ./md-unwind-support.h:57
#1 uw_frame_state_for (context=context@entry=0x7fffffffdf50, fs=fs@entry=0x7fffffffe040) at /usr/src/debug/gcc/gcc/libgcc/unwind-dw2.c:1016
#2 0x00007ffff7bf4fde in _Unwind_RaiseException (exc=0x555555d762f0) at /usr/src/debug/gcc/gcc/libgcc/unwind.inc:104
#3 0x00007ffff6eb2167 in __cxxabiv1::__cxa_throw (obj=<optimized out>, tinfo=0x7ffff7b2a0e8 <typeinfo for f3d::scene::load_failure_exception>, dest=0x7ffff75c3830 <f3d::scene::load_failure_exception::~load_failure_exception()>)
at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/eh_throw.cc:93
#4 0x00007ffff75c14bb in f3d::detail::scene_impl::add (this=0x5555557f3660, buffer=0x7fffffffe5a0, size=240) at /home/glow/dev/f3d/f3d/src/library/src/scene_impl.cxx:323
#5 0x00007ffff7f9b598 in f3d_scene_add_buffer (scene=0x5555557f3660, buffer=0x7fffffffe5a0, size=240) at /home/glow/dev/f3d/f3d/src/c/scene_c_api.cxx:204
Describe the solution you'd like
- In all the C bindings, check each libf3d usage and handle any exceptions that can be thrown.
- In the catch blocks, log an error using the
log API and return a failure value if possible.
- Document the behavior
Is your feature request related to a problem? Please describe.
libf3d recently added C bindings, however exception handling was skipped.
Triggering an exception from the C binding is completely non-descriptive and cannot be handled properly from the C code, the C binding should handle exceptions instead.
Describe the solution you'd like
logAPI and return a failure value if possible.