This is an archive of the discontinued LLVM Phabricator instance.

Switch from using member_clang_type.GetByteSize() to member_type->GetByteSize() in ParseSingleMember
ClosedPublic

Authored by shafik on May 13 2021, 2:41 PM.

Details

Summary

We have a bug in which using member_clang_type.GetByteSize() triggers record layout and during this process since the record was not yet complete we ended up reaching a record that had not been layed out yet. Using member_type->GetByteSize() avoids this situation since it relies on size from DWARF and will not trigger record layout.

We were not able to reduce this to minimal reproducer. The crash goes away in this case when we have a dSYM and we have seen that ordering in symbol processing can change the behavior as well.

For reference: rdar://77293040

Diff Detail

Event Timeline

shafik requested review of this revision.May 13 2021, 2:41 PM
shafik created this revision.
aprantl accepted this revision.May 13 2021, 6:46 PM

The change itself seems good to me, I wonder what we can do to prevent a similar mistake in the future.

This revision is now accepted and ready to land.May 13 2021, 6:46 PM

I guess we could add least add a comment like this?

// By calling member_type instead of member_clang_type, the size comes from DWARF, which avoids premature record layout.
teemperor accepted this revision.May 14 2021, 1:50 AM

I think this can just land as an optimisation. If we can read the size from DWARF (e.g., just returning the stored size int) then that's much better than computing the layout for some type.

This revision was landed with ongoing or failed builds.May 17 2021, 10:36 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2021, 10:36 AM