Bug 398183 - Vex errors with _mm256_shuffle_epi8/vpshufb.
Summary: Vex errors with _mm256_shuffle_epi8/vpshufb.
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: vex (show other bugs)
Version: 3.13 SVN
Platform: Ubuntu Linux
: NOR crash
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-03 08:54 UTC by secretmailkde123
Modified: 2019-03-12 17:56 UTC (History)
0 users

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


Attachments
Sample program triggering the issue. (7.98 KB, text/x-csrc)
2018-09-03 08:54 UTC, secretmailkde123
Details

Note You need to log in before you can comment on or make changes to this bug.
Description secretmailkde123 2018-09-03 08:54:40 UTC
Created attachment 114755 [details]
Sample program triggering the issue.

Hi,

We have some problems running valgrind with our project. It fails in numerous locations, all related to usage of _mm256_shuffle_epi8(). Based on this I have made a simple example program that shows the same error. 
Note that this program is not performing any real work. It generates 2 different errors depending on what compiler flags used.

test@test:~/valgrind_test$ gcc-7 -march=native -O2 main.c
test@test:~/valgrind_test$ valgrind ./a.out 
==18841== Memcheck, a memory error detector
==18841== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==18841== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==18841== Command: ./a.out
==18841== 

valgrind: m_translate.c:1796 (vgPlain_translate): Assertion 'tres.status == VexTransOK' failed.

host stacktrace:
==18841==    at 0x5803FC3D: show_sched_status_wrk (m_libcassert.c:355)
==18841==    by 0x5803FD44: report_and_quit (m_libcassert.c:426)
==18841==    by 0x5803FED1: vgPlain_assert_fail (m_libcassert.c:492)
==18841==    by 0x5805DCA8: vgPlain_translate (m_translate.c:1796)
==18841==    by 0x58093C5A: handle_chain_me (scheduler.c:1084)
==18841==    by 0x580957EF: vgPlain_scheduler (scheduler.c:1428)
==18841==    by 0x580A48FA: thread_wrapper (syswrap-linux.c:103)
==18841==    by 0x580A48FA: run_a_thread_NORETURN (syswrap-linux.c:156)

sched status:
  running_tid=1

Thread 1: status = VgTs_Runnable (lwpid 18841)
==18841==    at 0x400576: main (in /home/runeerle/temp/valgrind_test/a.out)



test@test:~/valgrind_test$ gcc-7 -mavx2 -O2 main.c
test@test:~/valgrind_test$ valgrind ./a.out 
==18821== Memcheck, a memory error detector
==18821== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==18821== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==18821== Command: ./a.out
==18821== 

vex: priv/host_generic_reg_alloc2.c:457 (doRegisterAllocation): Assertion `instrs_in->arr_used <= 15000' failed.
vex storage: T total 74491472 bytes allocated
vex storage: P total 640 bytes allocated

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

host stacktrace:
==18821==    at 0x5803FC3D: show_sched_status_wrk (m_libcassert.c:355)
==18821==    by 0x5803FD44: report_and_quit (m_libcassert.c:426)
==18821==    by 0x5803FF81: panic (m_libcassert.c:502)
==18821==    by 0x5803FF81: vgPlain_core_panic_at (m_libcassert.c:507)
==18821==    by 0x5803FFAA: vgPlain_core_panic (m_libcassert.c:512)
==18821==    by 0x5805B262: failure_exit (m_translate.c:740)
==18821==    by 0x58109EC8: vex_assert_fail (main_util.c:223)
==18821==    by 0x5817EC58: doRegisterAllocation (host_generic_reg_alloc2.c:457)
==18821==    by 0x58108C8F: libvex_BackEnd (main_main.c:1071)
==18821==    by 0x58108C8F: LibVEX_Translate (main_main.c:1174)
==18821==    by 0x5805D733: vgPlain_translate (m_translate.c:1794)
==18821==    by 0x58093C5A: handle_chain_me (scheduler.c:1084)
==18821==    by 0x580957EF: vgPlain_scheduler (scheduler.c:1428)
==18821==    by 0x580A48FA: thread_wrapper (syswrap-linux.c:103)
==18821==    by 0x580A48FA: run_a_thread_NORETURN (syswrap-linux.c:156)

sched status:
  running_tid=1

Thread 1: status = VgTs_Runnable (lwpid 18821)
==18821==    at 0x4006D9: main (in /home/runeerle/temp/valgrind_test/a.out)


The sample program fails the same way with, gcc version 7.2.0, gcc version 6.3.0 and gcc version 5.4.1.
System: Ubuntu 16.04
CPU: Intel(R) Core(TM) i7-5820K CPU

Ps. I believe we also got the error "Increase N_{TEMPORARY,PERMANENT}_BYTES and recompile.", and tried this as well.


Regards.
Comment 1 Julian Seward 2019-03-12 17:56:17 UTC
This failure happened because the translations of some AVX instructions
were very poor (excessively verbose), and your test case has a huge
block of them.  

I can no longer reproduce this on the trunk.  I think that's because
I made a bunch of fixes for exactly these kinds of problems during
Dec 2018 and Jan 2019.  So I think this is fixed.