Bug 443314 - In the latest GIT version, Valgrind with "--trace-flags" crashes at "al" register
Summary: In the latest GIT version, Valgrind with "--trace-flags" crashes at "al" regi...
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Paul Floyd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-04 17:13 UTC by Tanya
Modified: 2021-10-09 21:05 UTC (History)
1 user (show)

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


Attachments
Reproducer (67 bytes, text/plain)
2021-10-04 17:13 UTC, Tanya
Details
Possible fix (743 bytes, patch)
2021-10-04 17:13 UTC, Tanya
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tanya 2021-10-04 17:13:06 UTC
Created attachment 142148 [details]
Reproducer

SUMMARY
Valgrind trace (debug) crashes at "al" register after GIT commits 22bae4b1 and 61307ee8.

STEPS TO REPRODUCE
Attached a reproducer (al_test.c).
1. Compile the attached file:
> gcc al_test.c
2. Run it under Valgrind with debugging:
> valgrind --trace-flags=10000000  --trace-notbelow=0 ./a.out > vg_trace

OBSERVED RESULT
The trace file ends with an error message:

 vex: priv/guest_amd64_toIR.c:946 (nameIReg): Assertion `reg >= 4 && reg < 8' failed.
 vex storage: T total 53281728 bytes allocated
 vex storage: P total 512 bytes allocated

 valgrind: the 'impossible' happened:
    LibVEX called failure_exit().
 
 host stacktrace:
 ==442872==    at 0x580285F2: show_sched_status_wrk (m_libcassert.c:406)
 ==442872==    by 0x580286F7: report_and_quit (m_libcassert.c:477)
 ==442872==    by 0x58028935: vgPlain_core_panic_at (m_libcassert.c:553)
 ==442872==    by 0x5802895A: vgPlain_core_panic (m_libcassert.c:563)
 ==442872==    by 0x58040112: failure_exit (m_translate.c:766)
 ==442872==    by 0x580FE9A8: vex_assert_fail (main_util.c:249)
 ==442872==    by 0x5813EF4D: nameIRegRexB (guest_amd64_toIR.c:946)
 ==442872==    by 0x58158F03: dis_ESC_NONE.isra.50 (guest_amd64_toIR.c:21060)
 ==442872==    by 0x581A35C7: disInstr_AMD64_WRK (guest_amd64_toIR.c:32980)

EXPECTED RESULT
The trace file does not contain error messages

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION

The cause is, function "nameIRegRexB" classifies "al" as "irregular", while other functions, like "getIRegRexB", correctly classify it as regular.

Attached a fix (al_debug_fix.patch).
Comment 1 Tanya 2021-10-04 17:13:38 UTC
Created attachment 142149 [details]
Possible fix
Comment 2 Paul Floyd 2021-10-07 11:59:02 UTC
I'll take a look at this and try to get it into 3.18.
Comment 3 Paul Floyd 2021-10-09 21:05:21 UTC
Change committed with
commit 1c57706fbdc7f4ebd866aeade0900f437942f44c