This is an archive of the discontinued LLVM Phabricator instance.

[modules] Fix crash in call to `FunctionDecl::setPure()`
ClosedPublic

Authored by andrewjcg on Aug 30 2020, 2:00 PM.

Details

Summary

In some cases, when deserializing a CXXMethodDecl of a CXXSpecializationTemplateDecl,
the call to FunctionDecl::setPure() happens before the DefinitionData member has been
populated (which appears to happen lower down in a mergeRedeclarable call), causing a
crash (https://reviews.llvm.org/P8228).

This diff fixes this by deferring the FunctionDecl::setPure() till after the DefinitionData has
been filled in.

Diff Detail

Event Timeline

andrewjcg created this revision.Aug 30 2020, 2:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 30 2020, 2:00 PM
andrewjcg requested review of this revision.Aug 30 2020, 2:00 PM
andrewjcg retitled this revision from [modules] Repro for pure virtual base class method crash to [modules] Fix crash in call to `FunctionDecl::setPure()`.Aug 30 2020, 2:00 PM
andrewjcg edited the summary of this revision. (Show Details)Aug 30 2020, 2:27 PM
andrewjcg added a reviewer: bruno.
bruno added inline comments.
clang/lib/Serialization/ASTReaderDecl.cpp
874

pure -> Pure

clang/test/Modules/set-pure-crash.cpp
3

To speed this up a little, instead of -O0 -emit-llvm just use -fsyntax-only

andrewjcg updated this revision to Diff 289506.Sep 2 2020, 10:16 AM
andrewjcg marked 2 inline comments as done.

feedback

lxfind accepted this revision.Nov 18 2020, 11:43 AM
This revision is now accepted and ready to land.Nov 18 2020, 11:43 AM
This revision was automatically updated to reflect the committed changes.

@rsmith, @v.g.vassilev hey I stamped this patch assuming it looks ok. But definitely shout at me if more feedback needs to be addressed. Happy to follow up.

bruno added a comment.Nov 18 2020, 2:16 PM

I forgot to follow up, but LGTM too.

@rsmith, @v.g.vassilev hey I stamped this patch assuming it looks ok. But definitely shout at me if more feedback needs to be addressed. Happy to follow up.

FWIW, this has been working on our code base for sometime now.