From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 119000 invoked by alias); 25 Oct 2017 04:42:00 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 118984 invoked by uid 89); 25 Oct 2017 04:41:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=believed X-HELO: gproxy10-pub.mail.unifiedlayer.com Received: from gproxy10-pub.mail.unifiedlayer.com (HELO gproxy10-pub.mail.unifiedlayer.com) (69.89.20.226) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 25 Oct 2017 04:41:58 +0000 Received: from cmgw4 (unknown [10.0.90.85]) by gproxy10.mail.unifiedlayer.com (Postfix) with ESMTP id C1911140622 for ; Tue, 24 Oct 2017 22:41:56 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw4 with id Rght1w00G2f2jeq01ghwW8; Tue, 24 Oct 2017 22:41:56 -0600 X-Authority-Analysis: v=2.2 cv=JNNLi4Cb c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=02M-m0pO-4AA:10 a=VqVHnXkgoLfLY_CDqm4A:9 Received: from 71-218-90-63.hlrn.qwest.net ([71.218.90.63]:54058 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1e7DVp-0042bQ-7i; Tue, 24 Oct 2017 22:41:53 -0600 From: Tom Tromey To: Simon Marchi Cc: Tom Tromey , Subject: Re: [RFA 3/3] Remove cleanups from break-catch-syscall.c References: <20171018040645.7212-1-tom@tromey.com> <20171018040645.7212-3-tom@tromey.com> <280a7994-38a6-2138-b199-8902ee2651b0@ericsson.com> Date: Wed, 25 Oct 2017 04:42:00 -0000 In-Reply-To: <280a7994-38a6-2138-b199-8902ee2651b0@ericsson.com> (Simon Marchi's message of "Fri, 20 Oct 2017 16:26:15 -0400") Message-ID: <87tvynrg8h.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-BWhitelist: no X-Exim-ID: 1e7DVp-0042bQ-7i X-Source-Sender: 71-218-90-63.hlrn.qwest.net (bapiya) [71.218.90.63]:54058 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes X-SW-Source: 2017-10/txt/msg00754.txt.bz2 Simon> It is not enough to assign holders.back ().c_str () (after having pushed the string in Simon> the vector), because when the vector gets reallocated it can now point to stale memory. Simon> I think we have to do it in two pass, prepare the vector of std::string, and then get Simon> pointers to the strings. Sorry about that. I think I considered this after the earlier review and believed that the resizing wouldn't affect the locations; my thinking being that growing the vector must surely use the move constructor to move the strings into place -- since isn't this pretty much the whole reason rvalues even exist? But perhaps this doesn't happen sometimes for some reason. Your patch seems reasonable to me. Tom