Bug 1383522 - false error report for aarch64 "str q0, [sp,#-16]!"
Summary: false error report for aarch64 "str q0, [sp,#-16]!"
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: valgrind
Version: 29
Hardware: aarch64
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Mark Wielaard
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-10-10 23:06 UTC by Josh Stone
Modified: 2019-11-27 19:05 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-11-27 19:05:03 UTC
Type: Bug


Attachments (Terms of Use)

Description Josh Stone 2016-10-10 23:06:52 UTC
Description of problem:
Valgrind reports an error on "str q0, [sp,#-16]!" which looks fine to me.

Version-Release number of selected component (if applicable):
valgrind-3.12.0-0.3.BETA1.fc26.aarch64
rust-1.12.0-5.fc26.aarch64

How reproducible:
100%

Steps to Reproduce:
1. valgrind rustc -V

Actual results:
==896== Invalid write of size 8
==896==    at 0x4AF3280: std::thread::Builder::name::h830c87465509c1aa (in /usr/lib64/libstd-40393716.so)
==896==    by 0x4981D23: rustc_driver::run::ha6bc7b823ad700af (in /usr/lib64/librustc_driver-40393716.so)
==896==    by 0x498F477: rustc_driver::main::h1cac4fa29a384d12 (in /usr/lib64/librustc_driver-40393716.so)
==896==    by 0x4B3381B: __rust_maybe_catch_panic (in /usr/lib64/libstd-40393716.so)
==896==    by 0x4B26373: std::rt::lang_start::h53bf99b0829cc03c (in /usr/lib64/libstd-40393716.so)
==896==    by 0x4C0F46F: (below main) (in /usr/lib64/libc-2.24.90.so)
==896==  Address 0xfff00e930 is on thread 1's stack
==896==  16 bytes below stack pointer

Expected results:
No errors. (hopefully!)

Additional info:
I used vgdb to get the disassembly at the mapped address - not sure if there's a more direct way.  AIUI a "str q0, [sp,#-16]!" is basically a "push q0" because it's a pre-inc store, so it will update sp before writing the 128-bit q0.  Valgrind's note about being "below stack pointer" is only true compared to the prior sp.  That it calls this a "write of size 8", not 16 for q0, makes me think it's probably not decoding this instruction correctly.

(gdb) p $sp
$1 = (void *) 0xfff00e940
(gdb) disassemble /r
Dump of assembler code for function _ZN3std6thread7Builder4name17h830c87465509c1aaE:
   0x0000000004af3254 <+0>:     f6 57 bd a9     stp     x22, x21, [sp,#-48]!
   0x0000000004af3258 <+4>:     f4 4f 01 a9     stp     x20, x19, [sp,#16]
   0x0000000004af325c <+8>:     fd 7b 02 a9     stp     x29, x30, [sp,#32]
   0x0000000004af3260 <+12>:    fd 83 00 91     add     x29, sp, #0x20
   0x0000000004af3264 <+16>:    e9 03 01 aa     mov     x9, x1
   0x0000000004af3268 <+20>:    ea 03 00 aa     mov     x10, x0
   0x0000000004af326c <+24>:    40 05 40 a9     ldp     x0, x1, [x10]
   0x0000000004af3270 <+28>:    34 55 40 a9     ldp     x20, x21, [x9]
   0x0000000004af3274 <+32>:    36 09 40 f9     ldr     x22, [x9,#16]
   0x0000000004af3278 <+36>:    40 81 c1 3c     ldur    q0, [x10,#24]
   0x0000000004af327c <+40>:    f3 03 08 aa     mov     x19, x8
=> 0x0000000004af3280 <+44>:    e0 0f 9f 3c     str     q0, [sp,#-16]!
   0x0000000004af3284 <+48>:    40 01 00 b4     cbz     x0, 0x4af32ac <_ZN3std6thread7Builder4name17h830c87465509c1aaE+88>
   0x0000000004af3288 <+52>:    21 01 00 b4     cbz     x1, 0x4af32ac <_ZN3std6thread7Builder4name17h830c87465509c1aaE+88>
   0x0000000004af328c <+56>:    a8 a3 e3 d2     mov     x8, #0x1d1d000000000000         // #2097833001424519168
   0x0000000004af3290 <+60>:    a8 a3 c3 f2     movk    x8, #0x1d1d, lsl #32
   0x0000000004af3294 <+64>:    a8 a3 a3 f2     movk    x8, #0x1d1d, lsl #16
   0x0000000004af3298 <+68>:    a8 a3 83 f2     movk    x8, #0x1d1d
   0x0000000004af329c <+72>:    3f 00 08 eb     cmp     x1, x8
   0x0000000004af32a0 <+76>:    60 00 00 54     b.eq    0x4af32ac <_ZN3std6thread7Builder4name17h830c87465509c1aaE+88>
   0x0000000004af32a4 <+80>:    e2 03 00 32     orr     w2, wzr, #0x1
   0x0000000004af32a8 <+84>:    42 e7 ff 97     bl      0x4aecfb0 <__rust_deallocate@plt>
   0x0000000004af32ac <+88>:    e0 03 c0 3d     ldr     q0, [sp]
   0x0000000004af32b0 <+92>:    74 56 00 a9     stp     x20, x21, [x19]
   0x0000000004af32b4 <+96>:    76 0a 00 f9     str     x22, [x19,#16]
   0x0000000004af32b8 <+100>:   60 82 81 3c     stur    q0, [x19,#24]
   0x0000000004af32bc <+104>:   bf 83 00 d1     sub     sp, x29, #0x20
   0x0000000004af32c0 <+108>:   fd 7b 42 a9     ldp     x29, x30, [sp,#32]
   0x0000000004af32c4 <+112>:   f4 4f 41 a9     ldp     x20, x19, [sp,#16]
   0x0000000004af32c8 <+116>:   f6 57 c3 a8     ldp     x22, x21, [sp],#48
   0x0000000004af32cc <+120>:   c0 03 5f d6     ret
End of assembler dump.

In a larger problem I was debugging earlier, one error report like this multiplied into many other "uninitialized value" errors related to that stack memory, which made so much noise that valgrind was unusable for the actual problem at hand.

Comment 1 Fedora End Of Life 2017-02-28 10:25:40 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 26 development cycle.
Changing version to '26'.

Comment 2 Fedora End Of Life 2018-05-03 08:25:52 UTC
This message is a reminder that Fedora 26 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 26. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '26'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 26 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 3 Josh Stone 2018-05-03 17:49:31 UTC
AFAICS, current rust builds don't have that exact instruction anymore, and "valgrind rustc -V" doesn't complain.  However, installing the old packages into rawhide, newer valgrind still has the same complaint.

# rpm -q valgrind rust llvm-libs
valgrind-3.13.0-18.fc29.aarch64
rust-1.12.0-5.fc26.aarch64
llvm-libs-3.8.0-1.fc25.aarch64

# valgrind rustc -V
==32== Memcheck, a memory error detector
==32== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==32== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==32== Command: rustc -V
==32==
==32== Invalid write of size 8
==32==    at 0x4AA9280: std::thread::Builder::name (in /usr/lib64/libstd-40393716.so)
==32==    by 0x4945D23: rustc_driver::run (in /usr/lib64/librustc_driver-40393716.so)
==32==    by 0x4953477: rustc_driver::main (in /usr/lib64/librustc_driver-40393716.so)
==32==    by 0x4AE981B: __rust_maybe_catch_panic (in /usr/lib64/libstd-40393716.so)
==32==    by 0x4ADC373: std::rt::lang_start (in /usr/lib64/libstd-40393716.so)
==32==    by 0x4BB7C1F: (below main) (in /usr/lib64/libc-2.26.90.so)
==32==  Address 0x1ffefffb30 is on thread 1's stack
==32==  16 bytes below stack pointer

Maybe we could write a target with manual asm to reproduce the error directly.

Comment 4 Josh Stone 2018-05-03 18:00:32 UTC
int main() {
    asm volatile (
        "str q0, [sp,#-16]! \n"
        "ldr q0, [sp], #16  \n"
        );
    return 0;
}


==42== Invalid write of size 8
==42==    at 0x40055C: main (in /tmp/foo)
==42==  Address 0x1fff000440 is on thread 1's stack
==42==  16 bytes below stack pointer

Comment 5 Jan Kurik 2018-08-14 10:21:42 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 29 development cycle.
Changing version to '29'.

Comment 6 Ben Cotton 2019-10-31 20:51:46 UTC
This message is a reminder that Fedora 29 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 29 on 2019-11-26.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '29'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 29 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 7 Ben Cotton 2019-11-27 19:05:03 UTC
Fedora 29 changed to end-of-life (EOL) status on 2019-11-26. Fedora 29 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.