public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Yinyu Cai <caiyinyu@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc] x86: Fix bug about glibc.cpu.hwcaps.
Date: Tue,  7 Mar 2023 13:42:55 +0000 (GMT)	[thread overview]
Message-ID: <20230307134255.647033858D3C@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4c721f24fc190d1dc935eb0bab283de7cf13182e

commit 4c721f24fc190d1dc935eb0bab283de7cf13182e
Author: caiyinyu <caiyinyu@loongson.cn>
Date:   Tue Feb 28 16:21:41 2023 +0800

    x86: Fix bug about glibc.cpu.hwcaps.
    
    Recorded in [BZ #30183]:
    
    1. export GLIBC_TUNABLES=glibc.cpu.hwcaps=-AVX512
    2. Add  _dl_printf("p -- %s\n", p); just before switch(nl) in
       sysdeps/x86/cpu-tunables.c
    3. compiled and run ./testrun.sh /usr/bin/ls
    you will get:
    
    p -- -AVX512
    p -- LC_ADDRESS=en_US.UTF-8
    p -- LC_NUMERIC=C
    ...
    
    The function, TUNABLE_CALLBACK (set_hwcaps)
    (tunable_val_t *valp), checks far more than it should and it
    should stop at end of "-AVX512".

Diff:
---
 sysdeps/x86/cpu-tunables.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sysdeps/x86/cpu-tunables.c b/sysdeps/x86/cpu-tunables.c
index d3e1367bda..772fb0c4c2 100644
--- a/sysdeps/x86/cpu-tunables.c
+++ b/sysdeps/x86/cpu-tunables.c
@@ -107,13 +107,13 @@ TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp)
      NOTE: the IFUNC selection may change over time.  Please check all
      multiarch implementations when experimenting.  */
 
-  const char *p = valp->strval;
+  const char *p = valp->strval, *c;
   struct cpu_features *cpu_features = &GLRO(dl_x86_cpu_features);
   size_t len;
 
   do
     {
-      const char *c, *n;
+      const char *n;
       bool disable;
       size_t nl;
 
@@ -283,7 +283,7 @@ TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp)
 	}
       p += len + 1;
     }
-  while (*p != '\0');
+  while (*c != '\0');
 }
 
 # if CET_ENABLED

                 reply	other threads:[~2023-03-07 13:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230307134255.647033858D3C@sourceware.org \
    --to=caiyinyu@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).