Skip to content
This repository has been archived by the owner on Jan 26, 2025. It is now read-only.

12367081: UIStringDrawing methods are no longer thread safe in iOS 6 #14407

Open
openradar-mirror opened this issue Apr 18, 2016 · 0 comments
Open

Comments

@openradar-mirror
Copy link

Description

Summary:

Using any UIStringDrawing methods on two threads simultaneously causes a crash. My understanding was that all UIStringDrawing methods were thread safe from iOS 4.0.

Steps to Reproduce:

This code (that does nothing of any use) demonstrates the problem:

dispatch_queue_t queue = dispatch_queue_create("com.queue", NULL);

for (int i = 0; i < 10000; i++) {

    dispatch_async(queue, ^{

        NSString *string = @"My string";
        CGSize size = [string sizeWithFont:[UIFont boldSystemFontOfSize:13]];
    });
}

for (int i = 0; i < 10000; i++) {

    NSString *string = @"My string";
    CGSize size = [string sizeWithFont:[UIFont boldSystemFontOfSize:13]];
}

dispatch_release(queue);

The app crashes after a few iterations of the loops with the following backtrace:

Expected Results:

My understanding was that UIStringDrawing methods were thread safe from iOS 4. I expect that these loops should complete with no errors.

Actual Results:

The app crashes after a few iterations of the loops with EXC_BAD_ACCESS.

Regression:

• The crash occurs when running on an iPhone running iOS 6 (tested on iPhone 5).
• The crash does NOT occur when running on an iPhone running iOS 5 (tested on iPhone 4).
• The crash does NOT occur when running in the simulator (tested with iOS 6).
• The crash does NOT occur if only the foreground or only the background loop is run. Both foreground and background loops are required to cause a crash.

Product Version: 6.0
Created: 2012-09-25T13:42:45.588676
Originated: 2012-09-25T14:38:00
Open Radar Link: http://www.openradar.me/12367081

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

1 participant