-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FunctionPointerBase::call() no check for valid if fptr has been set #83
Comments
ARM Internal Ref: IOTSFW-1012 |
What is the expected failure mode? What is a valid pointer? In the C world, if you call an invalid Function Pointer, the results are either a null-pointer dereference (if it was 0), an alignment error (if Ideally, I'd like to see two system APIs to deal with this problem: pointerValid(uint8_t pmask, void *ptr);
pointerException(void *ptr);
Otherwise, the current state of things is exactly what you expect from function pointers. |
We're planning to create a generic debug delegation API for uvisor: This will allow uVisor and other system components to submit sophisticated debug messages without understanding where they end up (NV-logging, mesh network, Ethernet, USB etc.). The "drop-dead" functions is included as well - currently we have a blinkcode for fault-reason. |
Valid in the above context was meant to be as they are set to not NULL, not to point to nothing as stated in the FunctionPointerBase. FunctionPointerBase provides the method clear(), similar to what its ctor does - set both variables referenced in the report to NULL. Calling call() causes then null-pointer dereference. I recall in the old FunctionPointer there was a check present in the call() method. |
Sure, and while there's a small performance overhead for that check, it's something we could disable, possibly with yotta config. What I still don't have is an expected failure mode. An assert is probably the only thing we can do at the moment. Clearing a function pointer, then calling it is still no worse than: void (*foo)() = NULL;
foo(); While it's great that we can perform a check, I want to make sure that the result of performing the check is meaningful. That means: assert, breakpoint, watchdog reset, halt-and-catch-fire... There needs to be a meaningful failure mode. |
The point of the non-null pointer failure modes was to demonstrate that simply checking for |
FunctionPointerBase method call()
does not check if _membercaller or _object are valid.
The text was updated successfully, but these errors were encountered: