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

Merged
merged 1 commit into from
Apr 29, 2025

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

1 similar comment
@vsapsai
Copy link
Author

vsapsai commented Apr 28, 2025

@swift-ci please test

@vsapsai vsapsai merged commit 9f89297 into stable/20240723 Apr 29, 2025
3 checks passed
@vsapsai vsapsai deleted the eng/PR-139319683-cherry-pick branch April 29, 2025 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants