<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>485487</bug_id>
          
          <creation_ts>2024-04-13 14:12:05 +0000</creation_ts>
          <short_desc>glibc built with -march=x86-64-v3 does not work due to ld.so strcmp</short_desc>
          <delta_ts>2025-03-11 11:22:56 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>6</classification_id>
          <classification>Developer tools</classification>
          <product>valgrind</product>
          <component>memcheck</component>
          <version>3.23 GIT</version>
          <rep_platform>Other</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.kde.org/show_bug.cgi?id=501348</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Florian Weimer">fweimer</reporter>
          <assigned_to name="Julian Seward">jseward</assigned_to>
          <cc>fweimer</cc>
    
    <cc>mark</cc>
    
    <cc>sam</cc>
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2311285</commentid>
    <comment_count>0</comment_count>
      <attachid>168460</attachid>
    <who name="Florian Weimer">fweimer</who>
    <bug_when>2024-04-13 14:12:05 +0000</bug_when>
    <thetext>Created attachment 168460
valgrind-amd64-redir-strcmp.patch

This was originally observed as a glibc test case failure:

    [PATCH] x86_64: Suppress false positive valgrind error
    &lt;https://inbox.sourceware.org/libc-alpha/20240226000326.3844791-1-hjl.tools@gmail.com/&gt;

However, the analysis was incorrect, and the test failure actually shows that the newly built glibc is incompatible with valgrind. I think it&apos;s necessary to add a redirector for strcmp.

We see this in Fedora with valgrind-3.22.0-7.fc40.x86_64, which already has one AVX2 inline strcmp fix applied.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2311316</commentid>
    <comment_count>1</comment_count>
    <who name="Mark Wielaard">mark</who>
    <bug_when>2024-04-13 15:08:04 +0000</bug_when>
    <thetext>The proposed patch looks reasonable. Did you test it?
Is there a (fedora?) glibc build that triggers this issue?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2311317</commentid>
    <comment_count>2</comment_count>
    <who name="Florian Weimer">fweimer</who>
    <bug_when>2024-04-13 15:16:33 +0000</bug_when>
    <thetext>(In reply to Mark Wielaard from comment #1)
&gt; The proposed patch looks reasonable. Did you test it?

Sort of, the valgrind build passed, and the run-time failures are gone. Earlier versions of the patch with an incorrect implementation failed really spectacularly. But I do not write x86-64 assembly for a living (well, not really), so take it with a grain of salt.

&gt; Is there a (fedora?) glibc build that triggers this issue?

We had a glibc build bug/RPM spec file issue that resulted in rawhide binaries not using x86-64-v3 string functions in ld.so, and I missed the incorrect glibc upstream testsuite change at the time. We have this as a redundant test in glibc.spec that fails the Fedora build, that&apos;s how I noticed. We are getting better at not producing a glibc that is totally incompatible with valgrind. But all this means that there is no Fedora build. 8-)

I can prepare a rawhide scratch build for you if this helps, though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2311324</commentid>
    <comment_count>3</comment_count>
    <who name="Florian Weimer">fweimer</who>
    <bug_when>2024-04-13 15:34:47 +0000</bug_when>
    <thetext>H.J. suggests to use the implementation from &lt;https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/i386/i686/strcmp.S;h=e71d97f2a63a2d3c31e4c1be395c1a1f5e0200ff;hb=HEAD&gt; (adapted for x86-64). I can submit that if there are no licensing concerns.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2311344</commentid>
    <comment_count>4</comment_count>
    <who name="Florian Weimer">fweimer</who>
    <bug_when>2024-04-13 17:50:10 +0000</bug_when>
    <thetext>Based on a further suggestion from H.J., I put the strcmp implementation posted here into glibc and ran its strcmp test suite against it. It passes. For such a simple implementation it should have really good coverage. So I think the posted implementation should be okay.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2311346</commentid>
    <comment_count>5</comment_count>
    <who name="Mark Wielaard">mark</who>
    <bug_when>2024-04-13 17:56:03 +0000</bug_when>
    <thetext>(In reply to Florian Weimer from comment #4)
&gt; Based on a further suggestion from H.J., I put the strcmp implementation
&gt; posted here into glibc and ran its strcmp test suite against it. It passes.
&gt; For such a simple implementation it should have really good coverage. So I
&gt; think the posted implementation should be okay.

Yes. The license would be fine. But simpler is actually better for valgrind.
The code will run on the virtual machine and will be instrumented by tools.

I&apos;ll add it to the next fedora rawhide valgrind build so we can test it a bit more.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2311368</commentid>
    <comment_count>6</comment_count>
    <who name="Mark Wielaard">mark</who>
    <bug_when>2024-04-13 19:27:14 +0000</bug_when>
    <thetext>(In reply to Mark Wielaard from comment #5)
&gt; I&apos;ll add it to the next fedora rawhide valgrind build so we can test it a
&gt; bit more.

There is now valgrind-3.22.0-8.fc41 with this and some other (x86-64-v3) fixes to try out.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-7579427715</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2311486</commentid>
    <comment_count>7</comment_count>
    <who name="Mark Wielaard">mark</who>
    <bug_when>2024-04-14 09:29:56 +0000</bug_when>
    <thetext>There is now also an fedora eln build:
https://koji.fedoraproject.org/koji/buildinfo?buildID=2437715
Since eln is build with -march=x86-64-v3 this might be a good testing environment.

Please let me know if you are able to build/test a glibc against one of the above packages with this patch applied.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2311581</commentid>
    <comment_count>8</comment_count>
    <who name="Florian Weimer">fweimer</who>
    <bug_when>2024-04-14 17:20:11 +0000</bug_when>
    <thetext>The ELN glibc scratch build succeeded: https://src.fedoraproject.org/rpms/glibc/pull-request/92#comment-194579

There&apos;s a TMT failure, but it&apos;s unrelated (potential kernel robust mutex issue). This test does not run under valgrind anyway.

(That POWER10 work fixed some glibc.spec issues, which exposed the pre-existing x86-64-v3 bug.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2311603</commentid>
    <comment_count>9</comment_count>
    <who name="Mark Wielaard">mark</who>
    <bug_when>2024-04-14 20:19:54 +0000</bug_when>
    <thetext>commit dad279b80c1da4fb2c842cca9783ad0e49339ddc
Author: Florian Weimer &lt;fweimer@redhat.com&gt;
Date:   Sun Apr 14 21:56:03 2024 +0200

    add_hardwired_spec for ld-linux-x86-64.so.2 strcmp
    
    glibc built with -march=x86-64-v3 does not work due to ld.so strcmp
    
    https://bugs.kde.org/show_bug.cgi?id=485487</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>168460</attachid>
            <date>2024-04-13 14:12:05 +0000</date>
            <delta_ts>2024-04-13 14:12:05 +0000</delta_ts>
            <desc>valgrind-amd64-redir-strcmp.patch</desc>
            <filename>valgrind-amd64-redir-strcmp.patch</filename>
            <type>text/plain</type>
            <size>2181</size>
            <attacher name="Florian Weimer">fweimer</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL2NvcmVncmluZC9tX3JlZGlyLmMgYi9jb3JlZ3JpbmQvbV9yZWRpci5jCmlu
ZGV4IGNlZjI0MWI0Zjg1YWFkMjMuLmNlNjA3M2E2MjE5MGE2MzkgMTAwNjQ0Ci0tLSBhL2NvcmVn
cmluZC9tX3JlZGlyLmMKKysrIGIvY29yZWdyaW5kL21fcmVkaXIuYwpAQCAtMTQxMCw2ICsxNDEw
LDE1IEBAIHZvaWQgVkdfKHJlZGlyX2luaXRpYWxpc2UpICggdm9pZCApCiAgICAgICAgICBjb21w
bGFpbl9hYm91dF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