You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bagder opened this issue
Aug 13, 2021
· 2 comments
· Fixed by #2624
Labels
A-ffiArea: ffi (C API)C-bugCategory: bug. Something is wrong. This is bad!E-easyEffort: easy. A task that would be a great starting point for a new contributor.
I accidentally called hyper_waker_wake() with a NULL pointer argument. That leads to a subsequent segfault deep inside hyper at a later point which makes it difficult to debug. (25 stack frames in from my C code no less).
I expected to see this happen: in a debug-version of hyper maybe an assert should trigger. Or the NULL should just be ignored. It should not lead to a crash much later (when the executor poll is called).
The text was updated successfully, but these errors were encountered:
Heh, yea, kaboom indeed. Several of the functions that return a hyper_code do check for any passed NULLs and return a "bad argument" error. Other functions that don't expect to fail, I could add a debug assert. Silently ignoring may make things worse...
Yes, I totally see how this was my fault. It just turned out rather hard to figure out exactly where the problem was since the crash happens so far away from my error.
This changes all the extern C functions in `hyper::ffi` to check passed
pointer arguments for being `NULL` before trying to use them. Before, we
would just assume the programmer had passed a good pointer, which could
result in segmentation faults. Now:
- In debug builds, it will assert they aren't null, and so if they are,
a message identifying the argument name will be printed and then the
process will crash.
- In release builds, it will still check for null, but if found, it will
return early, with a return value indicating failure if the return type
allows (such as returning NULL, or `HYPERE_INVALID_ARG`).
Closes#2620
A-ffiArea: ffi (C API)C-bugCategory: bug. Something is wrong. This is bad!E-easyEffort: easy. A task that would be a great starting point for a new contributor.
Version
0.14.11 built from commit 684f2fa
Platform
Linux
Description
I accidentally called
hyper_waker_wake()
with a NULL pointer argument. That leads to a subsequent segfault deep inside hyper at a later point which makes it difficult to debug. (25 stack frames in from my C code no less).I expected to see this happen: in a debug-version of hyper maybe an assert should trigger. Or the NULL should just be ignored. It should not lead to a crash much later (when the executor poll is called).
The text was updated successfully, but these errors were encountered: