Bug 484935 - [patch] Valgrind reports false "Conditional jump or move depends on uninitialised value" errors for aarch64 signal handlers
Summary: [patch] Valgrind reports false "Conditional jump or move depends on uninitial...
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Paul Floyd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-02 17:18 UTC by Peter Edwards
Modified: 2024-04-03 09:21 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Test showing erroneous behaviour for linux/aarch64 (1.37 KB, text/x-csrc)
2024-04-02 17:18 UTC, Peter Edwards
Details
Patch for issue (1.93 KB, patch)
2024-04-02 17:19 UTC, Peter Edwards
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Edwards 2024-04-02 17:18:08 UTC
Created attachment 168062 [details]
Test showing erroneous behaviour for linux/aarch64

Accessing the arguments to signal handlers in aarch64 binaries can create "Conditional jump or move depends on uninitialized value" diagnostics.

Comparing the code for the aarch64 signal frame creation to that for x86_64 shows the problem - the values for the registers used for passing arguments (X0 thru X3) are modified, but the required `VG_TRACK( post_reg_write, ...` macros are not invoked to indicate that the registers now have well defined values. Adding these VG_TRACK macros in fixes the issue.

The attached test.c shows the problem under `valgrind` without the fix, but succeeds with it.
Comment 1 Peter Edwards 2024-04-02 17:19:13 UTC
Created attachment 168063 [details]
Patch for issue
Comment 2 Paul Floyd 2024-04-02 18:15:34 UTC
I fully agree with this.

I've done a port to FreeBSD arm64 and I did exactly the same thing

https://github.com/paulfloyd/freebsdarm64_valgrind/commit/d6d97cb954ef10c66ee117f536f92659dcbacf65
Comment 3 Paul Floyd 2024-04-02 18:26:55 UTC
I'll need to make a few changes to the testcase (so that it compiles on FreeBSD and doesn't have an infinite loop).
Comment 4 Paul Floyd 2024-04-03 06:35:01 UTC
Change and slightly modified test pushed. Thanks!

commit 97854e557ebc5df690103808a45fa282d5adfd96 (HEAD -> master, origin/master, origin/HEAD)
Author: Paul Floyd <pjfloyd@wanadoo.fr>
Date:   Wed Apr 3 08:32:12 2024 +0200

    Bug 484935 - [patch] Valgrind reports false "Conditional jump or move depends on uninitialised value" errors for aarch64 signal handlers
    
    Patch contributed by Peter Edwards <peadar@arista.com>
    
    Testcase modified and added to a new directory, memcheck/tests/arm64
Comment 5 Peter Edwards 2024-04-03 09:00:18 UTC
Thanks for the fast turn-around!
Comment 6 Paul Floyd 2024-04-03 09:21:45 UTC
(In reply to Peter Edwards from comment #5)
> Thanks for the fast turn-around!

You're welcome. It helps that I'd already done the same. I wish that more issues here coule be so easy.