This is an archive of the discontinued LLVM Phabricator instance.

[clang][USR] Prevent crashes when parameter lists have nulls
AbandonedPublic

Authored by kadircet on Mar 22 2023, 8:20 AM.

Details

Summary

Similar to D146426

Diff Detail

Event Timeline

kadircet created this revision.Mar 22 2023, 8:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 22 2023, 8:20 AM
Herald added a subscriber: arphaman. · View Herald Transcript
kadircet requested review of this revision.Mar 22 2023, 8:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 22 2023, 8:20 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

I am aware that this null checking at leaves are not considered a sustainable solution and I agree with the sentiment there. But we're seeing an increasing number of crashes in production on invalid code recently. Happy to take a different course if there are alternatives, but as also explained in D146426, the situation around parameter lists having nullptrs seem to be the state for a long time now, e.g:

template <typename T> auto x = [](__fp16) {};
decltype(x<int>);

is a reproducer that crashes even clang-12 due to a nullptr in the paremeter list. Surely it'd be better to fix this invariant, but I am afraid we don't know how to do that immediately and considering people have been dealing with this situation by adding null checks into the places that triggered crashes ever since, I'd like to move forward with this fix until someone can figure out the situation.

I am aware that this null checking at leaves are not considered a sustainable solution and I agree with the sentiment there. But we're seeing an increasing number of crashes in production on invalid code recently. Happy to take a different course if there are alternatives, but as also explained in D146426, the situation around parameter lists having nullptrs seem to be the state for a long time now, e.g:

template <typename T> auto x = [](__fp16) {};
decltype(x<int>);

is a reproducer that crashes even clang-12 due to a nullptr in the paremeter list. Surely it'd be better to fix this invariant, but I am afraid we don't know how to do that immediately and considering people have been dealing with this situation by adding null checks into the places that triggered crashes ever since, I'd like to move forward with this fix until someone can figure out the situation.

IMO, if the increasing number of crashes is a concern, now is the time to fix it properly instead of continuing to play whack-a-mole. To me, "fix it properly" means ensuring that we don't have null AST nodes, but if during investigation there's a more foundational problem that prevents us from doing that, we can make a different decision once we have more information.

ilya-biryukov added a comment.EditedMar 27 2023, 8:12 AM

Hopefully this should be addressed by D146971, but it would be great to get a reproducer for this issue to be certain.

kadircet updated this revision to Diff 508934.Mar 28 2023, 1:49 AM
  • Add test
Herald added a project: Restricted Project. · View Herald TranscriptMar 28 2023, 1:49 AM
kadircet abandoned this revision.May 3 2023, 2:38 AM

in favor of D149733