From b05481a8c89c80d28b6c15907db52c9cd0667379 Mon Sep 17 00:00:00 2001 From: Frederik Seiffert Date: Fri, 26 Mar 2021 11:07:45 +0100 Subject: [PATCH] Don't resurrect GSFileHandle singletons. It seems to be no longer possible to call -retain from -dealloc with the latest libobjc2, which was causing the tests to fail. We are also throwing an exception in this case, which would need to be specifically caught in order for the resurrection to be of value to users, so this simply removes the -retain call and resets the singleton variables to nil in order to not have invalid pointers and for the singletons to be re-created on subsequent access. --- Source/GSFileHandle.m | 6 +++--- Tests/base/NSFileHandle/singleton.m | 6 ------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Source/GSFileHandle.m b/Source/GSFileHandle.m index dc4980265..c8cc9651c 100644 --- a/Source/GSFileHandle.m +++ b/Source/GSFileHandle.m @@ -351,19 +351,19 @@ static GSTcpTune *tune = nil; { if (self == fh_stdin) { - RETAIN(self); + fh_stdin = nil; [NSException raise: NSGenericException format: @"Attempt to deallocate standard input handle"]; } if (self == fh_stdout) { - RETAIN(self); + fh_stdout = nil; [NSException raise: NSGenericException format: @"Attempt to deallocate standard output handle"]; } if (self == fh_stderr) { - RETAIN(self); + fh_stderr = nil; [NSException raise: NSGenericException format: @"Attempt to deallocate standard error handle"]; } diff --git a/Tests/base/NSFileHandle/singleton.m b/Tests/base/NSFileHandle/singleton.m index 792632e69..ade40c848 100644 --- a/Tests/base/NSFileHandle/singleton.m +++ b/Tests/base/NSFileHandle/singleton.m @@ -15,15 +15,9 @@ int main(void) b = [NSFileHandle fileHandleWithStandardOutput]; c = [NSFileHandle fileHandleWithStandardError]; END_SET("handle creation") - PASS([a retainCount]> 0, "stdin persists"); - PASS([b retainCount]> 0, "stdout persists"); - PASS([c retainCount]> 0, "strerr persists"); PASS_EXCEPTION([a release], NSGenericException, "Cannot dealloc stdin"); PASS_EXCEPTION([b release], NSGenericException, "Cannot dealloc stdout"); PASS_EXCEPTION([c release], NSGenericException, "Cannot dealloc stderr"); - PASS([a retainCount]> 0, "stdin persists"); - PASS([b retainCount]> 0, "stdout persists"); - PASS([c retainCount]> 0, "strerr persists"); [p drain]; return 0;