From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 79795 invoked by alias); 1 Oct 2019 18:27:47 -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 79583 invoked by uid 89); 1 Oct 2019 18:27:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.0 required=5.0 tests=AWL,BAYES_00,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_PASS,USER_IN_DEF_SPF_WL autolearn=ham version=3.3.1 spammy= X-HELO: mail-ot1-f68.google.com Received: from mail-ot1-f68.google.com (HELO mail-ot1-f68.google.com) (209.85.210.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 01 Oct 2019 18:27:45 +0000 Received: by mail-ot1-f68.google.com with SMTP id y39so12436847ota.7 for ; Tue, 01 Oct 2019 11:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3xKBdkkcJSEVcUaRH6XD4HGq3xyqrztSY7GwksItWGc=; b=BUqJWEDzs4Cw1OtajbAvE8BOK1uXUR8jYyQol66VwpDoc56eHVcMoTSSyIlZypbjs9 3qiMRuFbxJr7Zv3QiLfg03pEi6wf+qYfK69NGAXaHh0vbFYay4n2Hd+r/dqQ9X89ssgh 3XpMw/+honTe+7UvLmiGebgLEO0ytkJN2UxhlkIScv0Lns5PHQ1O5Gtzgg8qtzs5x4Qj jmzkylVzjkDcf5gUn0CM7WomMBjO+f3VXsj/O7pg0171QjytEE6NTq3W3h0b01EqByhN di7qVJFbrCim/OPgnVbIx+IySu0sOA6TMmfrCIR7JfxWA2Szzsm11AJqBWJOQG+bpc7I Qppw== MIME-Version: 1.0 References: <20191001173345.48753-1-cbiesinger@google.com> In-Reply-To: From: "Christian Biesinger via gdb-patches" Reply-To: Christian Biesinger Date: Tue, 01 Oct 2019 18:27:00 -0000 Message-ID: Subject: Re: [PATCH] Change some arguments to gdb::string_view instead of name+len To: Pedro Alves Cc: gdb-patches Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg00029.txt.bz2 On Tue, Oct 1, 2019 at 1:23 PM Pedro Alves wrote: > > On 10/1/19 6:33 PM, Christian Biesinger via gdb-patches wrote: > > - if (linkage_name[len] != '\0') > > + /* Don't use string_view::operator[] because we are accessing beyond > > + the size of the string_view, which is technically unsupported. */ > > + if (linkage_name.data ()[linkage_name.length ()] != '\0') > > { > > char *alloc_name; > > It's more than just unsupported, it's undefined behavior. If we're promising > the string_view interface, then it's supposedly valid to pass in a string_view > that happens to point just at the end of a page, with the one-past-the-end > byte living in an unmapped page. Dereferencing the one-past-end byte in > that case SIGSEGVs. That's true (though also a pre-existing issue). > > - if (ms_type == mst_file_text && startswith (name, "__gnu_compiled")) > > + if (ms_type == mst_file_text && startswith (name.data (), "__gnu_compiled")) > > return (NULL); > > > > This, via startswith also assumes that name.data() is a null-terminated > string. Ah yes. I'll add a startswith version that takes string_views. > I wonder whether we should have a zstring_view type. like string_view, but > assumes/requires null-terminated. How does that solve anything? This function can (apparently) take non-null terminated strings, so zstring_view wouldn't work? Christian