Skip to content

Commit

Permalink
Leak the global static mutex in CKTextKitContext to avoid static dest…
Browse files Browse the repository at this point in the history
…ructor 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
  • Loading branch information
ocrickard authored and facebook-github-bot committed May 1, 2018
1 parent d80335c commit 37bcfdb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ComponentTextKit/TextKit/CKTextKitContext.mm
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ - (instancetype)initWithAttributedString:(NSAttributedString *)attributedString
{
if (self = [super init]) {
// Concurrently initialising TextKit components crashes (rdar://18448377) so we use a global lock.
static std::mutex __static_mutex;
std::lock_guard<std::mutex> l(__static_mutex);
static std::mutex *__static_mutex = new std::mutex;
std::lock_guard<std::mutex> l(*__static_mutex);
// Create the TextKit component stack with our default configuration.
_textStorage = (attributedString ? [[NSTextStorage alloc] initWithAttributedString:attributedString] : [[NSTextStorage alloc] init]);
_layoutManager = layoutManagerFactory ? layoutManagerFactory() : [[NSLayoutManager alloc] init];
Expand Down

0 comments on commit 37bcfdb

Please sign in to comment.