Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

dispatch_barrier_async can lead to inconsistent values when using mutable objects

Open
#2 1 comment 0 reactions 0 assignees View on GitHub

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:

  1. NSMutableDictionary *registeredDefaults = [[NSMutableDictionary alloc] init];
  2. [[NSUserDefaults standardUserDefaults] registerDefaults:registeredDefaults];
  3. [registeredDefaults setObject:@"FOO" forKey:@"BAR"];
  4. 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Flipboard/NSUserDefaultsSimulatorPerformanceBoost

All issues in Flipboard/NSUserDefaultsSimulatorPerformanceBoost

Similar issues

More Objective-C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.