Make --ftrace more crash proof with foreign code

Sometimes we need to interact with code that wasn't compiled using
`-fno-omit-frame-pointer`. For example, if a function pointer gets
passed and called by a foreign function, linked by cosmo_dlopen().
Function call tracing will now detect backtrace pointer corruption
and simply reduce the indentation level back to zero, as a result.
This commit is contained in:
Justine Tunney 2024-02-22 11:06:31 -08:00
parent 38af54a2dd
commit e9a756e78b
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
2 changed files with 6 additions and 1 deletions

View file

@ -51,7 +51,7 @@ static struct CosmoFtrace g_ftrace;
__funline int GetNestingLevelImpl(struct StackFrame *frame) {
int nesting = -2;
while (frame) {
while (frame && !kisdangerous(frame)) {
++nesting;
frame = frame->next;
}