dispatch_barrier_async can lead to inconsistent values when using mutable objects
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- objective-c
- Domain
- devtools
Research direction
Start by reproducing the reported registerDefaults and mutable-object setObject:forKey: cases with simulator performance enabled and disabled, then trace the dispatch_barrier_async handling. Done means mutations follow NSUserDefaults behavior consistently rather than depending on barrier timing or performance mode.
Written by the indexing model from the issue text.
Description
dispatch_barrier_async works great for this project, except for the following situation:
- NSMutableDictionary *registeredDefaults = [[NSMutableDictionary alloc] init];
- [[NSUserDefaults standardUserDefaults] registerDefaults:registeredDefaults];
- [registeredDefaults setObject:@"FOO" forKey:@"BAR"];
- NSObject *value = [[NSUserDefaults standardUserDefaults] objectForKey:@"BAR"];
- With sim performance ON, value may be equal to nil or equal to @"FOO" depending on if line 3 executed before the internal barrier_async block executed.
- With sim performance OFF, value is always equal to nil. Mutations after line 2 are not acknowledged.
The code above is incorrect anyways (you wouldn't expect it to work) -- but we still need to honor the behavior of NSUserDefaults. You could emulate this bug using -setObject:forKey: with a mutable object.
- Dominant language
- Objective-C
- Stars
- 40
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Flipboard/NSUserDefaultsSimulatorPerformanceBoost
-
Add unit testsOpen
Difficulty 3/5 1-2 days Newbie friendliness 20/100
All issues in Flipboard/NSUserDefaultsSimulatorPerformanceBoost
Similar issues
-
!
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
osmandapp/OsmAnd-iOS#5912 ·
Maintainers usually reply within 1 day
-
React-Native Waiting for: Product Owner
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
getsentry/sentry-react-native#6822 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-2 days Newbie friendliness 78/100
getsentry/sentry-cocoa#9219 · 1 comment ·
Maintainers usually reply within 1 day
-
feature-request
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
DataDog/dd-sdk-ios#3255 · 1 comment ·
Maintainers usually reply within 3 days
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
repowise-dev/repowise#2785 ·
Maintainers usually reply within 1 day