Bug 276780

Summary: An instruction in fftw (Fast Fourier Transform) is unhandled by valgrind: vex x86->IR: unhandled instruction bytes: 0x66 0xF 0x3A 0x22
Product: [Developer tools] valgrind Reporter: Youssief <egad>
Component: generalAssignee: Paul Floyd <pjfloyd>
Status: RESOLVED FIXED    
Severity: normal CC: pjfloyd, tom
Priority: NOR    
Version First Reported In: 3.6.0   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Implement PINSRD on x86
Added testcase NEWS and .gitignore

Description Youssief 2011-06-29 20:58:15 UTC
Version:           3.6.0 (using KDE 4.6.3) 
OS:                Linux

Hi

I am using the fftw3 library for fast fourier transform.
It always exits with an error of "Illegal Instruction"
The mesage I get is this

vex x86->IR: unhandled instruction bytes: 0x66 0xF 0x3A 0x22

The instruction that causes this in my program always happens when I try to create the fft plan using
fftw_plan_r2r_1d(n_time_points, fftw_real_in         , fftw_half_complex_out , FFTW_R2HC , FFTW_MEASURE);

Reproducible: Always

Steps to Reproduce:
Compile the file below using 
 g++ ./main.cpp -lfftw3 -o myfile

and then run valgrind using 

valgrind --leak-check=full --log-file=valgrind_hispice.txt ./myfile


---------------------------------------

#include <fftw3.h>





int main (int argc, char **argv)
{
 
 int n_time_points = 20;
  double* fftw_real_in          = (double *) fftw_malloc(sizeof(double) * n_time_points);
   double* fftw_real_out         = (double *) fftw_malloc(sizeof(double) * n_time_points);
    double* fftw_half_complex_in  = (double *) fftw_malloc(sizeof(double) * n_time_points);
    double* fftw_half_complex_out = (double *) fftw_malloc(sizeof(double) * n_time_points);

    fftw_plan hb_fft_plan     = fftw_plan_r2r_1d(n_time_points, fftw_real_in         , fftw_half_complex_out , FFTW_R2HC , FFTW_MEASURE);

}

Actual Results:  
The log file is below
---------------------

==27142== Memcheck, a memory error detector
==27142== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==27142== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
==27142== Command: ./myfile
==27142== Parent PID: 2625
==27142== 
vex x86->IR: unhandled instruction bytes: 0x66 0xF 0x3A 0x22
==27142== valgrind: Unrecognised instruction at address 0x809e5e6.
==27142== Your program just tried to execute an instruction that Valgrind
==27142== did not recognise.  There are two possible reasons for this.
==27142== 1. Your program has a bug and erroneously jumped to a non-code
==27142==    location.  If you are running Memcheck and you just saw a
==27142==    warning about a bad jump, it's probably your program's fault.
==27142== 2. The instruction is legitimate but Valgrind doesn't handle it,
==27142==    i.e. it's Valgrind's fault.  If you think this is the case or
==27142==    you are not sure, please let us know and we'll try to fix it.
==27142== Either way, Valgrind will now raise a SIGILL signal which will
==27142== probably kill your program.
==27142== 
==27142== Process terminating with default action of signal 4 (SIGILL)
==27142==  Illegal opcode at address 0x809E5E6
==27142==    at 0x809E5E6: fftw_mkstride (in /home/egad/projects/HiSPICE/Hispice/myfile)
==27142== 
==27142== HEAP SUMMARY:
==27142==     in use at exit: 30,264 bytes in 631 blocks
==27142==   total heap usage: 664 allocs, 33 frees, 85,988 bytes allocated
==27142== 
==27142== 20 bytes in 1 blocks are definitely lost in loss record 1 of 9
==27142==    at 0x4024F20: malloc (vg_replace_malloc.c:236)
==27142==    by 0x8048B08: fftw_malloc_plain (in /home/egad/projects/HiSPICE/Hispice/myfile)
==27142== 
==27142== 5,576 bytes in 168 blocks are possibly lost in loss record 7 of 9
==27142==    at 0x4024F20: malloc (vg_replace_malloc.c:236)
==27142==    by 0x8048B08: fftw_malloc_plain (in /home/egad/projects/HiSPICE/Hispice/myfile)
==27142== 
==27142== 9,224 bytes in 443 blocks are possibly lost in loss record 8 of 9
==27142==    at 0x4024F20: malloc (vg_replace_malloc.c:236)
==27142==    by 0x8048B08: fftw_malloc_plain (in /home/egad/projects/HiSPICE/Hispice/myfile)
==27142==    by 0x42DB027: ???
==27142== 
==27142== LEAK SUMMARY:
==27142==    definitely lost: 20 bytes in 1 blocks
==27142==    indirectly lost: 0 bytes in 0 blocks
==27142==      possibly lost: 14,800 bytes in 611 blocks
==27142==    still reachable: 15,444 bytes in 19 blocks
==27142==         suppressed: 0 bytes in 0 blocks
==27142== Reachable blocks (those to which a pointer was found) are not shown.
==27142== To see them, rerun with: --leak-check=full --show-reachable=yes
==27142== 
==27142== For counts of detected and suppressed errors, rerun with: -v
==27142== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 17 from 6)

Expected Results:  
I should not have gotten the ILLEGAL instruction
Comment 1 Tom Hughes 2011-08-18 14:46:54 UTC
Created attachment 62953 [details]
Implement PINSRD on x86

That's PINSRD which is an SSE4 instruction we only seem to support on amd64 at the moment.

Please try this patch, which adds support for that instruction on x86 as well.
Comment 2 Dirk Mueller 2023-11-14 08:36:42 UTC
This patch builds and tests just fine. can you please get it submitted?
Comment 3 Paul Floyd 2023-11-14 09:14:21 UTC
I'll take a look
Comment 4 Paul Floyd 2024-05-13 18:45:12 UTC
Created attachment 169455 [details]
Added testcase NEWS and .gitignore
Comment 5 Paul Floyd 2024-05-13 20:00:53 UTC
commit 92b6fa13d4ecf075c434d0316d493383edf7aa6d (HEAD -> master, origin/master, origin/HEAD)
Author: Tom Hughes <tom@compton.nu>
Date:   Mon May 13 20:40:19 2024 +0200

    Bug 276780 - An instruction in fftw (Fast Fourier Transform) is unhandled by valgrind: vex x86->IR: unhandled instruction bytes: 0x66 0xF 0x3A 0x22