Skip to content

Avoid a crash when using external link support with certain unexpected inputs. #1200

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

Conversation

d-ronnqvist
Copy link
Contributor

Bug/issue #, if applicable: rdar://148504975

Summary

This avoids a crash by accessing the identifier that the path hierarchy internally uses as a key rather than the identifier that's saved on the node. These should always be equal but some unexpected input can cause the node to have a different identifier than what the path hierarchy uses to find that node. The root cause of that issue still remains. This only avoids a crash that arises as a symptoms of the real issue.

Dependencies

None.

Testing

Because the root cause of this issue is still unknown, I can't provide better testing instructions than:

  • Run docc convert --enable-experimental-external-link-support with some project that currently reproduces this crash.

Checklist

It's not possible to write an automated test for this change because any inputs necessary to create a path hierarchy where a node has a different identifier than the key in the lookup would fail to construct due to this assertion:

assert(
    lookup.allSatisfy({ $0.key == $0.value.identifier }),
    "Every node lookup should match a node with that identifier."
)
  • [ ] Added tests See above.
  • Ran the ./bin/test script and it succeeded
  • [ ] Updated documentation if necessary Not applicable

@d-ronnqvist
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@QuietMisdreavus QuietMisdreavus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@d-ronnqvist d-ronnqvist merged commit 1e61447 into swiftlang:main Apr 23, 2025
2 checks passed
@d-ronnqvist d-ronnqvist deleted the assert-node-identifiers-during-serialization branch April 23, 2025 07:33
d-ronnqvist added a commit to d-ronnqvist/swift-docc that referenced this pull request Apr 23, 2025
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.

2 participants