When exception that is not a subclass of StandardError happens inside custom sass function, it's not handled by SassC::FunctionsHandler and gets raised up to FFI::Function block body, where ffi gem silently catches it and treats as if block returned nil. This causes segmentation fault later in C code, when trying to dereference null pointer.
This changes rescue in functions_handler to handle all exceptions.
Recovering from non-StandardError might be not a good idea in general (for example when exception is NoMemoryError), but I didn't find proper ways to abort the whole process inside ffi callback. Tried Kernel#abort, it just prints error message and causes callback to return nil so the same segfault remains. Maybe using abort() libc function directly is an option but I doubt if it's portable enough between systems. So, I think, rescuing all exceptions is okay here.
fixes #244
When exception that is not a subclass of
StandardError
happens inside custom sass function, it's not handled bySassC::FunctionsHandler
and gets raised up toFFI::Function
block body, where ffi gem silently catches it and treats as if block returnednil
. This causes segmentation fault later in C code, when trying to dereference null pointer.This changes
rescue
infunctions_handler
to handle all exceptions.Recovering from non-
StandardError
might be not a good idea in general (for example when exception isNoMemoryError
), but I didn't find proper ways to abort the whole process inside ffi callback. TriedKernel#abort
, it just prints error message and causes callback to return nil so the same segfault remains. Maybe usingabort()
libc function directly is an option but I doubt if it's portable enough between systems. So, I think, rescuing all exceptions is okay here.