Skip to content

Commit

Permalink
Include ObjC class name of decode failures in crash logs' register va…
Browse files Browse the repository at this point in the history
…lues

https://bugs.webkit.org/show_bug.cgi?id=260871
rdar://114119254

Reviewed by David Kilzer.

Logs in rdar://113527046 indicate something occasionally crashes here, but we don't know what.
This will help gather information about what occasionally crashes.

* Source/WebKit/Shared/API/Cocoa/WKRemoteObjectCoder.mm:
(checkIfClassIsAllowed):

Canonical link: https://commits.webkit.org/267425@main
  • Loading branch information
achristensen07 committed Aug 29, 2023
1 parent a959acf commit df817db
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Source/WebKit/Shared/API/Cocoa/WKRemoteObjectCoder.mm
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,10 @@ static void checkIfClassIsAllowed(WKRemoteObjectDecoder *decoder, Class objectCl
if (alwaysAllowedClasses().contains((__bridge CFTypeRef)objectClass))
return;

[NSException raise:NSInvalidUnarchiveOperationException format:@"Object of class \"%@\" is not allowed. Allowed classes are \"%@\"", objectClass, decoder.allowedClasses];
NSString *message = [NSString stringWithFormat:@"%@,%@", NSStringFromClass(objectClass), decoder.allowedClasses];
std::array<uint64_t, 6> values { 0, 0, 0, 0, 0, 0 };
strncpy(reinterpret_cast<char*>(values.data()), message.UTF8String, sizeof(values));
CRASH_WITH_INFO(values[0], values[1], values[2], values[3], values[4], values[5]);
}

static void validateClass(WKRemoteObjectDecoder *decoder, Class objectClass)
Expand Down

0 comments on commit df817db

Please sign in to comment.