This is an archive of the discontinued LLVM Phabricator instance.

Don't use potentially invalidated iterator
ClosedPublic

Authored by sberg on Mar 24 2016, 4:50 AM.

Details

Summary

If the lhs is evaluated before the rhs, FuncletI's operator-> can trigger the

  
assert(isHandleInSync() && "invalid iterator access!");

at include/llvm/ADT/DenseMap.h:1061. (Happens e.g. when compiled with GCC 6.)

Diff Detail

Repository
rL LLVM

Event Timeline

sberg updated this revision to Diff 51536.Mar 24 2016, 4:50 AM
sberg retitled this revision from to Don't use potentially invalidated iterator.
sberg updated this object.
sberg added a reviewer: majnemer.
sberg added a subscriber: llvm-commits.
sberg added a comment.Mar 24 2016, 4:53 AM
  • That code had originally been introduced with David Majnemer's r249257 "[WinEH] Permit branch folding in the face of funclets", hence setting him as reviewer.
  • No idea what those int stored in FuncletMembership represent, so didn't come up with a better name than generic "n" for the var.
sberg added a comment.Mar 31 2016, 2:49 AM

friendly ping

(I have commit access now, so all it would need is a "lgtm" :)

LGTM, thanks!

(drop the const from const auto - we don't usually constify value types
defensively like that)

Also - what type is 'n'? Something simple/cheap? Or should it be referenced
by (const) ref instead of by value?

This revision was automatically updated to reflect the committed changes.
sberg added a comment.Mar 31 2016, 8:50 AM

Dropped the const. The type of n is int, so taking by value is fine. (But guess it's better to stick to auto, in case the value type of FuncletMembership should ever change.)