From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30513 invoked by alias); 20 Jun 2009 14:53:55 -0000 Received: (qmail 30505 invoked by uid 22791); 20 Jun 2009 14:53:54 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 20 Jun 2009 14:53:48 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n5KErkIw024717 for ; Sat, 20 Jun 2009 10:53:46 -0400 Received: from omfg.slc.redhat.com (vpn-12-181.rdu.redhat.com [10.11.12.181]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n5KErjmJ024847 for ; Sat, 20 Jun 2009 10:53:46 -0400 Message-ID: <4A3CF81C.7050406@redhat.com> Date: Sat, 20 Jun 2009 14:53:00 -0000 From: Jeff Law User-Agent: Thunderbird 2.0.0.21 (X11/20090320) MIME-Version: 1.0 To: GCC Subject: (known?) Issue with bitmap iterators Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-06/txt/msg00482.txt.bz2 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