[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.
This commit is contained in:
Yuta Saito 2024-10-09 21:46:15 +09:00
Родитель e00b746b75
Коммит c77f0b9134
1 изменённых файлов: 10 добавлений и 2 удалений

12
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 */