public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* (known?) Issue with bitmap iterators
@ 2009-06-20 14:53 Jeff Law
  2009-06-20 15:01 ` Richard Guenther
  2009-06-22  2:44 ` Daniel Berlin
  0 siblings, 2 replies; 22+ messages in thread
From: Jeff Law @ 2009-06-20 14:53 UTC (permalink / raw)
  To: GCC


Imagine a loop like this

EXECUTE_IF_SET_IN_BITMAP (something, 0, i, bi)
  {
    bitmap_clear_bit (something, i)
    [ ... whatever code we want to process i, ... ]
  }

This code is unsafe.

If bit I happens to be the only bit set in the current bitmap word, then 
bitmap_clear_bit will free the current element and return it to the 
element free list where it can be recycled.

So assume the bitmap element gets recycled for some other bitmap...  We 
then come around to the top of the loop where EXECUTE_IF_SET_IN_BITMAP 
will call bmp_iter_set which can reference the recycled element when it 
tries to advance to the next element via bi->elt1 = bi->elt1->next.  So 
we start iterating on elements of a completely different bitmap.  You 
can assume this is not good.

Our documentation clearly states that I is to remain unchanged, but ISTM 
that the bitmap we're iterating over needs to remain unchanged as well. 

Is this a known issue, or am I just the lucky bastard who tripped over 
it and now gets to audit all the EXECUTE_IF_SET_IN_BITMAP loops?

Jeff

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2009-07-01  6:48 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-20 14:53 (known?) Issue with bitmap iterators Jeff Law
2009-06-20 15:01 ` Richard Guenther
2009-06-21  3:27   ` Peter Bergner
2009-06-22 17:06   ` Jeff Law
2009-06-22 17:46     ` Joe Buck
2009-06-22 19:07       ` Dave Korn
2009-06-25 18:11         ` Daniel Berlin
2009-06-25 18:37       ` Jeff Law
2009-06-25 22:39         ` Dave Korn
2009-07-01  2:14           ` Jeff Law
2009-06-26 10:47         ` Alexander Monakov
2009-06-26 16:51           ` Joe Buck
2009-06-26 19:28             ` Alexander Monakov
2009-07-01  2:21               ` Jeff Law
2009-07-01  6:48                 ` Dave Korn
2009-06-22  2:44 ` Daniel Berlin
2009-06-22 11:33   ` Dave Korn
2009-06-22 11:37     ` Richard Guenther
2009-06-22 13:06       ` Dave Korn
2009-06-22 13:38         ` Paolo Bonzini
2009-06-22 19:03           ` Dave Korn
2009-06-22 14:27   ` Andrew MacLeod

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).