From patchwork Tue Jan 22 05:21:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Pluzhnikov X-Patchwork-Id: 214340 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id EFED52C007E for ; Tue, 22 Jan 2013 16:21:45 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1359436906; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:From:To:Cc:Subject:Date:Message-ID: MIME-Version:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=23SuK17SxE+eNGybTfYHXWK0v8g=; b=GvWdNRn14jWAO/r GqWVwcvt98g6RDOfWO1Deypk96TFR11QfUuZwuKv/fyS+1ZeTt8i7KW2XGnulNiC FohZPvrRd5prwp8vIJzWuDWqILRgQVmrof3VCVyZvUxnNQGkSgOG0bhO3lQ5yQkz zEo12HQ8HfGvKjysgSV1GdtJ3wnE= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:X-Received:Received:Received:Received:From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type:X-Gm-Message-State:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=ZNVML5MFadh8/YQLlnZwBXxoC+P8FS95anGJ2675hv7cnrCFV9Up0rInWsuE6t H5n2b4aTEj8jDXWVnDNiVcb2yCnQHXVKHVJ2eVxR5CZl6oH/ccT8YDOnjQq07Jb1 lycFiQh21PXqmcAPCpUvObZP5+Y1/gQkCRwSlTQV+Jw0g=; Received: (qmail 1225 invoked by alias); 22 Jan 2013 05:21:35 -0000 Received: (qmail 1212 invoked by uid 22791); 22 Jan 2013 05:21:33 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-yh0-f74.google.com (HELO mail-yh0-f74.google.com) (209.85.213.74) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 Jan 2013 05:21:26 +0000 Received: by mail-yh0-f74.google.com with SMTP id z12so503599yhz.1 for ; Mon, 21 Jan 2013 21:21:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:mime-version :content-type:x-gm-message-state; bh=ndqNweQ3fZ9pT0QUFh8skDjZBxfazL8MeZYU41djRwU=; b=lcm/8U1MhLbd+OCKBKP/Q5zHS+lcP9Wkr42VX1eYKxIEvIsk+7+fcLKT1GbpkjDIs4 qacLDGaIb9l+R8BVVhqawEUDUjiqfJ3wlX160PZaCZdUWFvUznBCS1RGul/T2tu5iU9U SqEZvfSYmg9TjMuzXtqHa0JExHXyV0bjSgFcty/BiJQivJh9562y3Y3O4heSpfJP+acB swVVEPB6a4nR1/jwF/JmV/T21LWa1JISjsM4KQEjXOz0vtI3KqXjUIjPH/DDNuUU6xOy XI7zOLtjTI92jfpF3+efF31ckhAgq1F+2j6SEqaKomfvxKxHAHmuNgOyUEUBeroU5RYZ VOBg== X-Received: by 10.236.140.108 with SMTP id d72mr9709097yhj.35.1358832085201; Mon, 21 Jan 2013 21:21:25 -0800 (PST) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id i63si681919yhk.5.2013.01.21.21.21.25 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Mon, 21 Jan 2013 21:21:25 -0800 (PST) Received: from elbrus2.mtv.corp.google.com (elbrus2.mtv.corp.google.com [172.17.128.95]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 123F331C05D; Mon, 21 Jan 2013 21:21:25 -0800 (PST) Received: by elbrus2.mtv.corp.google.com (Postfix, from userid 74925) id 97EB01C4A0F; Mon, 21 Jan 2013 21:21:24 -0800 (PST) From: Paul Pluzhnikov To: dnovillo@google.com, gcc-patches@gcc.gnu.org Cc: ppluzhnikov@google.com Subject: [google gcc-4_7, integration] Add more lightweight checks for dangling vectors Date: Mon, 21 Jan 2013 21:21:24 -0800 Message-ID: MIME-Version: 1.0 X-Gm-Message-State: ALoCoQk+CUK34cutl1JoUCXWbBagHG4gE5bf5S0yaB5DwygDyHzVyIKywACftT2pkC6tPgiIUzo9oPwf5b/z0fngJ3i7X/VZDpgQqxXBZXqyXfPb23EEeq0Vx6+WBicQ8oQcPsa47YcRm3ItJvOIL6MQLRLG2xAyHGLD0WV+SNavTG7WTNKsdJEKdr4AA11409GK5MRx1YxNWuAotP/E8y6DskOnlFpXTQrlfKJmWataxrBwn6WgR90= Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch sets destructed vector into an invalid state, such that subsequent calls to begin(), end(), size(), etc. all throw logic_error. Google ref b/7248326 Ok for google/gcc-4_7 and google/integration? Thanks, --- Paul Pluzhnikov Index: libstdc++-v3/include/bits/stl_vector.h =================================================================== --- libstdc++-v3/include/bits/stl_vector.h (revision 195356) +++ libstdc++-v3/include/bits/stl_vector.h (working copy) @@ -159,7 +159,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ~_Vector_base() { _M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage - - this->_M_impl._M_start); } + - this->_M_impl._M_start); +#if __google_stl_debug_dangling_vector + this->_M_impl._M_start = 0; + this->_M_impl._M_finish = reinterpret_cast<_Tp*>(~0UL); +#endif + } public: _Vector_impl _M_impl;