Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

SmallVector not safe to insert elements into itself #16252

Open Quuxplusone opened 11 years ago

Quuxplusone commented 11 years ago
Bugzilla Link PR16253
Status NEW
Importance P normal
Reported by David Blaikie (dblaikie@gmail.com)
Reported on 2013-06-06 21:57:31 -0700
Last modified on 2020-09-10 05:26:00 -0700
Version trunk
Hardware PC All
CC aschwaighofer@apple.com, atrick@apple.com, jduprat@apple.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, N.James93@hotmail.co.uk, rafael@espindo.la
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also

See 183465 and r183459 for an issue that arose because of this (& please revert that fix once this issue is addressed)

r178319 discusses a similar issue with vector wehre Howard Hinnant decreed that it was conforming & didn't add overhead to the vector implementation to do so - so we should do the same thing with SmallVector to avoid surprise

Quuxplusone commented 11 years ago
I have looked at what libc++ does and it (if out of space) allocates a new
vector buffer, copies the element and then deletes the old buffer so we should
do the same in small vector.

if (enough_space)
  copy element
else
  allocate new buffer
  copy element
  delete old buffer

this way smallvector.push_back(smallvector[x]) would be safe.
Quuxplusone commented 11 years ago

It looks like http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130401/170255.html is related and waiting to be reviewed.

Quuxplusone commented 4 years ago

I have started to work on a patch to address these pitfalls https://reviews.llvm.org/D87326