Skip to content

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

Merged
lorentey merged 1 commit intoapple:release/1.1from
lorentey:bogus-assert-in-Deque
May 28, 2024
Merged

[Deque]: Fix bogus assert in Deque._Storage._ensureUnique#381
lorentey merged 1 commit intoapple:release/1.1from
lorentey:bogus-assert-in-Deque

Conversation

@lorentey
Copy link
Copy Markdown
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
Copy Markdown
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
@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