Skip to content

[Modules] Fix the inconsistency of which Decl should be serialized for an identifier. #10552

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

Open
wants to merge 1 commit into
base: stable/20240723
Choose a base branch
from

Conversation

vsapsai
Copy link

@vsapsai vsapsai commented Apr 25, 2025

Fixes the assertion failure

Assertion failed: (DeclIDs.contains(D) && "Declaration not emitted!"),
function getDeclID, file ASTWriter.cpp, line 6873.

We prepare to serialize a Decl by adding it to DeclIDs in ASTWriter::GetDeclRef. But the checks before this call aren't the same as when we are actually serializing a Decl in
ASTIdentifierTableTrait::EmitData and
ASTWriter::WriteIdentifierTable. That's how we can end up serializing a Decl not present in DeclIDs and hitting the assertion. With the assertions disabled clang crashes when trying to use a deserialized null Decl.

Fix by making the code checks before ASTWriter::GetDeclRef call similar to those we have before the serialization.

rdar://139319683
(cherry picked from commit ebe084f)

…for an identifier. (llvm#135887)

Fixes the assertion failure
> Assertion failed: (DeclIDs.contains(D) && "Declaration not emitted!"),
function getDeclID, file ASTWriter.cpp, line 6873.

We prepare to serialize a `Decl` by adding it to `DeclIDs` in
`ASTWriter::GetDeclRef`. But the checks before this call aren't the same
as when we are actually serializing a `Decl` in
`ASTIdentifierTableTrait::EmitData` and
`ASTWriter::WriteIdentifierTable`. That's how we can end up serializing
a `Decl` not present in `DeclIDs` and hitting the assertion. With the
assertions disabled clang crashes when trying to use a deserialized null
`Decl`.

Fix by making the code checks before `ASTWriter::GetDeclRef` call
similar to those we have before the serialization.

rdar://139319683
(cherry picked from commit ebe084f)
@vsapsai vsapsai requested a review from a team as a code owner April 25, 2025 20:47
@vsapsai vsapsai requested a review from cyndyishida April 25, 2025 20:47
@cyndyishida
Copy link

Thank you, Volodymyr!

@vsapsai
Copy link
Author

vsapsai commented Apr 25, 2025

@swift-ci please test

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