Skip to content

Commit

Permalink
Canary mismatches are no longer fatal exceptions, they simply return …
Browse files Browse the repository at this point in the history
…the correct value so their callers can abandon work.
  • Loading branch information
cmsj committed Mar 9, 2022
1 parent 3bca009 commit 1348219
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions LuaSkin/LuaSkin/Skin.m
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,17 @@ - (BOOL)checkGCCanary:(LSGCCanary)canary {
NSLog(@"checkGCCanary (%@) comparing %@ vs %@", [NSThread.callStackSymbols objectAtIndex:1], self.uuid.UUIDString, NSlsCanary);
#endif
if (!NSlsCanary || ![self.uuid.UUIDString isEqualToString:NSlsCanary]) {
NSLog(@"LuaSkin caught an attempt to operate on an object that has been garbage collected.");
for (NSString *stackSymbol in [NSThread callStackSymbols]) {
NSLog(@"Previous stack symbol: %@", stackSymbol);
}
NSException* myException = [NSException
exceptionWithName:@"LuaGCCanaryMismatch"
reason:[NSString stringWithFormat:@"GC Canary changed: Expected %@, found %@", self.uuid.UUIDString, NSlsCanary]
userInfo:nil];
@throw myException;
// Throwing an exception is not helpful in production, because the whole point of the canary check is to discard events that are being delivered to stale Lua instances.
// We can hang onto the code anyway in case we need it later.
// NSLog(@"LuaSkin caught an attempt to operate on an object that has been garbage collected.");
// for (NSString *stackSymbol in [NSThread callStackSymbols]) {
// NSLog(@"Previous stack symbol: %@", stackSymbol);
// }
// NSException* myException = [NSException
// exceptionWithName:@"LuaGCCanaryMismatch"
// reason:[NSString stringWithFormat:@"GC Canary changed: Expected %@, found %@", self.uuid.UUIDString, NSlsCanary]
// userInfo:nil];
// @throw myException;
return NO;
}

Expand Down

0 comments on commit 1348219

Please sign in to comment.