From c77f0b91342935f661c6e5ba0f6f5c19427da174 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Wed, 9 Oct 2024 21:46:15 +0900 Subject: [PATCH] [Bug #20631] Workaround for macOS 15.0 fork crash macOS 15.0 24A5331b seems to have a weird issue that `CFStringCreateWithBytesNoCopy` does not return `NSTaggedPointerString` instance for the first call. This issue is fixed in macOS 15.1 but we need to workaround it for macOS 15.0. --- file.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/file.c b/file.c index 8edb0a3284..585dd90665 100644 --- a/file.c +++ b/file.c @@ -310,8 +310,16 @@ rb_CFString_class_initialize_before_fork(void) const char small_str[] = "/"; long len = sizeof(small_str) - 1; CFStringRef s; - CFMutableStringRef m = mutable_CFString_new(&s, small_str, len); - mutable_CFString_release(m, s); + /* + * Touch `CFStringCreateWithBytesNoCopy` *twice* because the implementation + * shipped with macOS 15.0 24A5331b does not return `NSTaggedPointerString` + * instance for the first call (totally not sure why). CoreFoundation + * shipped with macOS 15.1 does not have this issue. + */ + for (int i = 0; i < 2; i++) { + CFMutableStringRef m = mutable_CFString_new(&s, small_str, len); + mutable_CFString_release(m, s); + } } # endif /* HAVE_WORKING_FORK */