Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Deque]: Fix bogus assert in Deque._Storage._ensureUnique #381

Merged
merged 1 commit into from
May 28, 2024

Conversation

lorentey
Copy link
Member

A non-unique reference to a storage instance can legitimately become unique at any point, due to other references (say, held, by another thread) getting destroyed.

Deque’s ensureUnique implementation currently invokes the uniqueness check two times in quick succession, expecting it to return false both times. In rare circumstances, this can lead to a spurious trap in concurrent environments.

Fix this by avoiding calling isUnique more than once.

(We do not have a great way to exercise such concurrency issues, so this fix comes with no test case.)

Resolves #380

Checklist

  • I've read the Contribution Guidelines
  • My contributions are licensed under the Swift license.
  • I've followed the coding style of the rest of the project.
  • I've added tests covering all new code paths my change adds to the project (if appropriate).
  • I've added benchmarks covering new functionality (if appropriate).
  • I've verified that my change does not break any existing tests or introduce unexplained benchmark regressions.
  • I've updated the documentation if necessary.

A non-unique reference to a storage instance can legitimately become unique at any point, due to other references (say, held, by another thread) getting destroyed.

`Deque`’s `ensureUnique` implementation currently invokes the uniqueness check two times in quick succession, expecting it to return false both times. In rare circumstances, this can lead to a spurious trap in concurrent environments.

Fix this by avoiding calling `isUnique` more than once.
@lorentey lorentey added this to the 1.1.1 milestone May 24, 2024
@lorentey lorentey self-assigned this May 24, 2024
@lorentey
Copy link
Member Author

@swift-ci test

@lorentey lorentey linked an issue May 24, 2024 that may be closed by this pull request
@lorentey lorentey merged commit 1ada243 into apple:release/1.1 May 28, 2024
1 of 2 checks passed
@lorentey lorentey deleted the bogus-assert-in-Deque branch May 28, 2024 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid assert in Deque._ensureUnique
1 participant