From patchwork Fri Aug 13 18:26:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 44661 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B87A03890037 for ; Fri, 13 Aug 2021 18:27:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B87A03890037 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1628879231; bh=6KQjUP4g+eG0JeYoTcU0o4Wpchp4Ho9zwlzxn+ukDi4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=vkPpbUM+VE3+dnta7CdAFzqw1gAIKOODN1eexRHX+8p+oGc3C/W/JlAsVhA+a8jRJ YUpBfaZnjE/c1DH9Nrr4m3lAF5n0J9xK55WYPhQZu3UB/DKF3SMtgFVtFHTT43QfPL nGH4c3ejKw1wf8n2JoLk6Ls1XmeNBVxDH4nmUT78= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id 58EF3385C019 for ; Fri, 13 Aug 2021 18:26:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 58EF3385C019 Received: by mail-ot1-x333.google.com with SMTP id c2-20020a0568303482b029048bcf4c6bd9so13048742otu.8 for ; Fri, 13 Aug 2021 11:26:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=6KQjUP4g+eG0JeYoTcU0o4Wpchp4Ho9zwlzxn+ukDi4=; b=teJXnu6AGNoR+NPow/OcwLUcoP4++0mmyC3GpNUUc3BGw/B1zPK7SVgONFyCc36D0H Bsis3yR79QhN86pMl8//6MW1oZ8VPewiaSp+d721C08Wq6YEwdYiEyO/zEQHiIBeBf8Q rudgv1kacW/cHmOhAa6y5UH4Xfn0O/OLRl73jNNL5m56AN790pHuLGXGij6vlfioZCAD 1R9pp/Ge3X+Xk7fnfNgpr4x0X3Ar3u1c7JxBZdcXuWy7meuMDV7JAPIDeOOM3DEVV4lT fJqtaPyRWWBCXrXL9m8k9ObfD5ZNs/POBGQJqyurGgnzYBXuK//EfXqegNpG3B8MUlLp n8AQ== X-Gm-Message-State: AOAM532gmO2o6n6luuar4fi0ZwBbj8Nmr8YONEKzi2znQ/HuRw6FaQUr QHdS9kU1CwkRSWkszHop70VjIlZ+vHU= X-Google-Smtp-Source: ABdhPJzZF6KGOkRAR0v5RlZbLe+EHlb6EOb3D2nYxnNHhr8dMhxwbWE6o4KFWDZwZgts1cedxSi9ew== X-Received: by 2002:a05:6830:1185:: with SMTP id u5mr3186469otq.259.1628879199572; Fri, 13 Aug 2021 11:26:39 -0700 (PDT) Received: from [192.168.0.41] (97-118-104-61.hlrn.qwest.net. [97.118.104.61]) by smtp.gmail.com with ESMTPSA id d1sm232945otb.61.2021.08.13.11.26.39 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 13 Aug 2021 11:26:39 -0700 (PDT) To: GNU C Library Subject: [PATCH] remove attribute access from regexec Message-ID: <15a32181-8060-4135-cb72-9e79831697d5@gmail.com> Date: Fri, 13 Aug 2021 12:26:38 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Martin Sebor via Libc-alpha From: Martin Sebor Reply-To: Martin Sebor Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" A recent GCC enhancement to detect accesses by functions declared with attribute access that are in conflict with the mode specified by the attribute triggers a warning for the definition of regexec: regexec.c: In function ‘__regexec’: regexec.c:204:13: warning: ‘*pmatch.rm_so’ may be used uninitialized [-Wmaybe-uninitialized] regexec.c:192:101: note: accessing argument 4 of a function declared with attribute ‘access (write_only, 4, 3)’ The attribute was added based on the POSIX description of the function that implies the pmatch array referenced by it is write-only. However, when the REG_STARTEND bit is set in flags, Glibc also reads from the object. This seems to be an extension to POSIX that's not mentioned in the Glibc manual but that is documented in the Linux man pages: https://man7.org/linux/man-pages/man3/regcomp.3.html The patch below changes the attribute's mode to read_write to reflect this extension. Martin diff --git a/posix/regex.h b/posix/regex.h index 14fb1d8364..ba8351f873 100644 --- a/posix/regex.h +++ b/posix/regex.h @@ -656,7 +656,7 @@ extern int regexec (const regex_t *_Restrict_ __preg, const char *_Restrict_ __String, size_t __nmatch, regmatch_t __pmatch[_Restrict_arr_], int __eflags) - __attr_access ((__write_only__, 4, 3)); + __attr_access ((__read_write__, 4, 3)); extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg, char *_Restrict_ __errbuf, size_t __errbuf_size)