Bug 402481 - vbit-test fails on x86 for Iop_CmpEQ64 iselInt64Expr Sar64(Sub64(t14,Shr64(t14,0x1:I8)),0x3F:I8)
Summary: vbit-test fails on x86 for Iop_CmpEQ64 iselInt64Expr Sar64(Sub64(t14,Shr64(t1...
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: 3.15 SVN
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-23 00:02 UTC by Mark Wielaard
Modified: 2018-12-23 21:25 UTC (History)
0 users

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


Attachments
Also test memcheck/tests/vbit-test on any secondary arch. (2.61 KB, text/plain)
2018-12-23 12:33 UTC, Mark Wielaard
Details
Implement Iop_Sar64 in the x86 back end. (2.71 KB, patch)
2018-12-23 18:32 UTC, Julian Seward
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Wielaard 2018-12-23 00:02:15 UTC
Testing operator Iop_CmpEQ64
---------- Running a test
opnd #0:  vbits = 0000000000000001   value = 0000000000000000
opnd #1:  vbits = 0000000000000000   value = ffffffffffffffff
Sar64(Sub64(t14,Shr64(t14,0x1:I8)),0x3F:I8)
vex: the `impossible' happened:
   iselInt64Expr
vex storage: T total 383756044 bytes allocated
vex storage: P total 448 bytes allocated

valgrind: the 'impossible' happened:
   LibVEX called failure_exit().

host stacktrace:
==8063==    at 0x58050CDB: show_sched_status_wrk (m_libcassert.c:369)
==8063==    by 0x58050E39: report_and_quit (m_libcassert.c:440)
==8063==    by 0x58051015: panic (m_libcassert.c:516)
==8063==    by 0x58051015: vgPlain_core_panic_at (m_libcassert.c:521)
==8063==    by 0x58051046: vgPlain_core_panic (m_libcassert.c:526)
==8063==    by 0x580679D3: failure_exit (m_translate.c:751)
==8063==    by 0x5816AB8C: vpanic (main_util.c:255)
==8063==    by 0x581C0B78: iselInt64Expr_wrk (host_x86_isel.c:2865)
==8063==    by 0x581C0B78: iselInt64Expr (host_x86_isel.c:2075)
==8063==    by 0x581C1F68: iselInt64Expr_wrk (host_x86_isel.c:2241)
==8063==    by 0x581C1F68: iselInt64Expr (host_x86_isel.c:2075)
==8063==    by 0x581C6660: iselCondCode_wrk (host_x86_isel.c:1924)
==8063==    by 0x581C4AE5: iselCondCode (host_x86_isel.c:1782)
==8063==    by 0x581C4AE5: iselIntExpr_R_wrk (host_x86_isel.c:1298)
==8063==    by 0x581C4AE5: iselIntExpr_R (host_x86_isel.c:840)
==8063==    by 0x581C307A: doHelperCall.constprop.27 (host_x86_isel.c:595)
==8063==    by 0x581C82CB: iselStmt (host_x86_isel.c:4112)
==8063==    by 0x581C82CB: iselSB_X86 (host_x86_isel.c:4509)
==8063==    by 0x581679E0: libvex_BackEnd (main_main.c:1049)
==8063==    by 0x581679E0: LibVEX_Translate (main_main.c:1186)
==8063==    by 0x5806A7C4: vgPlain_translate (m_translate.c:1813)
==8063==    by 0x580B0076: handle_chain_me (scheduler.c:1134)
==8063==    by 0x580B2CEB: vgPlain_scheduler (scheduler.c:1477)
==8063==    by 0x58116F86: thread_wrapper (syswrap-linux.c:103)
==8063==    by 0x58116F86: run_a_thread_NORETURN (syswrap-linux.c:156)

sched status:
  running_tid=1

Thread 1: status = VgTs_Runnable (lwpid 8063)
==8063==    at 0x8052D6D: valgrind_vex_inject_ir (valgrind.c:110)
==8063==    by 0x8052D6D: valgrind_execute_test (valgrind.c:136)
==8063==    by 0x804C3F8: test_binary_op (binary.c:677)
==8063==    by 0x804891A: main (main.c:194)
client stack range: [0xFEC13000 0xFEC17FFF] client SP: 0xFEC16BAC
valgrind stack range: [0x82E8F000 0x82F8EFFF] top usage: 5812 of 1048576
Comment 1 Mark Wielaard 2018-12-23 00:50:11 UTC
This seems to come from expensiveCmpEQorNE () which will use an Iop_Sar64 (through mkOCastAt) for an Iop_CmpEQ64, which the x86 backend doesn't implement.
Comment 2 Julian Seward 2018-12-23 09:15:44 UTC
Arrgh.  I'll fix it.  Do you know if the same failure has occurred
for any other 32-bit targets, btw?
Comment 3 Mark Wielaard 2018-12-23 12:27:13 UTC
(In reply to Julian Seward from comment #2)
> Arrgh.  I'll fix it.  Do you know if the same failure has occurred
> for any other 32-bit targets, btw?

I haven't seen it on other 32-bit arches. I believe that is because arm32, mips32 and ppc32 don't implement Iop_CmpEQ64 and Iop_CmpNEQ64 (and so don't need Iop_Sar64). Only x86 implements both Iop_CmpEQ64 and Iop_CmpNEQ64, but not Iop_Sar64. (According to memcheck/tests/vbit-test/irops.c.)
Comment 4 Mark Wielaard 2018-12-23 12:33:17 UTC
Created attachment 117073 [details]
Also test memcheck/tests/vbit-test on any secondary arch.

This might make it slightly easier to test. When we build for a secondary arch then also build and run a secondary arch vbit-test. That way you can test this for x86 on x86_64.
Comment 5 Julian Seward 2018-12-23 18:32:52 UTC
Created attachment 117078 [details]
Implement Iop_Sar64 in the x86 back end.
Comment 6 Mark Wielaard 2018-12-23 20:29:15 UTC
(In reply to Julian Seward from comment #5)
> Created attachment 117078 [details]
> Implement Iop_Sar64 in the x86 back end.

Nice, this make the vbit-test test on x86 (and the vbit-test-sec test on amd64) pass.

Once you land this fix I like to add my vbit-test-sec patch to get a bit more memcheck test coverage on those arches which have sec-arch support.
Comment 7 Julian Seward 2018-12-23 21:04:33 UTC
Landed, d43c20b3913780276f2c97a62cd8fba376be8c64.

> Once you land this fix I like to add my vbit-test-sec patch to get a bit
> more memcheck test coverage on those arches which have sec-arch support.

Yes, please do.  That sounds very sensible.
Comment 8 Mark Wielaard 2018-12-23 21:25:53 UTC
commit d43c20b3913780276f2c97a62cd8fba376be8c64
Author: Julian Seward <jseward@acm.org>
Date:   Sun Dec 23 22:02:03 2018 +0100

    Bug 402481 - vbit-test fails on x86 for Iop_CmpEQ64 iselInt64Expr Sar64(Sub64(t14,Shr64(t14,0x1:I8)),0x3F:I8).
    
    Fixes the failure by implementing Iop_Sar64 in the x86 back end.

commit 49ca1853fccccd2d5cd63ac82fe9ad0954d2ea2d
Author: Mark Wielaard <mark@klomp.org>
Date:   Sun Dec 23 13:29:27 2018 +0100

    Also test memcheck/tests/vbit-test on any secondary arch.
    
    If we are building a secondary arch then also build and run the
    memcheck vbit-test for that architecture.