Skip to content

Commit 37bcfdb

Browse files
ocrickardfacebook-github-bot
authored andcommitted
Leak the global static mutex in CKTextKitContext to avoid static destructor fiasco
Summary: OSS CK is crashing on the exit. The probable cause is that it is static mutex is destroyed at the same time when another thread tries to lock it. This diff leaks the mutex in order to avoid that crash I haven't tested this code, but this is what I would try to resolve #892. Someone should run some smoke tests with something like the above Closes #906 Reviewed By: kfirapps Differential Revision: D7616427 Pulled By: gkassabli fbshipit-source-id: fe4d9fc1add8228d3bd672f853cca8d54a02bc58
1 parent d80335c commit 37bcfdb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ComponentTextKit/TextKit/CKTextKitContext.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ - (instancetype)initWithAttributedString:(NSAttributedString *)attributedString
3030
{
3131
if (self = [super init]) {
3232
// Concurrently initialising TextKit components crashes (rdar://18448377) so we use a global lock.
33-
static std::mutex __static_mutex;
34-
std::lock_guard<std::mutex> l(__static_mutex);
33+
static std::mutex *__static_mutex = new std::mutex;
34+
std::lock_guard<std::mutex> l(*__static_mutex);
3535
// Create the TextKit component stack with our default configuration.
3636
_textStorage = (attributedString ? [[NSTextStorage alloc] initWithAttributedString:attributedString] : [[NSTextStorage alloc] init]);
3737
_layoutManager = layoutManagerFactory ? layoutManagerFactory() : [[NSLayoutManager alloc] init];

0 commit comments

Comments
 (0)