Package: valgrind
Version: 1:3.5.0-3
Severity: normal
Running valgrind (memcheck) on my program compiled with g++-4.5, it
dies on an unrecognized instruction:
$ valgrind ./m4test
==18514== Memcheck, a memory error detector
==18514== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==18514== Using Valgrind-3.5.0-Debian and LibVEX; rerun with -h for
copyright info
==18514== Command: ./m4test
==18514==
vex amd64->IR: unhandled instruction bytes: 0x66 0xF 0x3A 0x21 0x42 0x1C
==18514== valgrind: Unrecognised instruction at address 0x4005b7.
==18514== Your program just tried to execute an instruction that Valgrind
==18514== did not recognise. There are two possible reasons for this.
==18514== 1. Your program has a bug and erroneously jumped to a non-code
==18514== location. If you are running Memcheck and you just saw a
==18514== warning about a bad jump, it's probably your program's fault.
==18514== 2. The instruction is legitimate but Valgrind doesn't handle it,
==18514== i.e. it's Valgrind's fault. If you think this is the case or
==18514== you are not sure, please let us know and we'll try to fix it.
==18514== Either way, Valgrind will now raise a SIGILL signal which will
==18514== probably kill your program.
==18514==
==18514== Process terminating with default action of signal 4 (SIGILL)
==18514== Illegal opcode at address 0x4005B7
==18514== at 0x4005B7: Matrix4::operator*(Matrix4 const&) const (in
/tmp/m4test)
==18514== by 0x40050B: main (in /tmp/m4test)
==18514==
==18514== HEAP SUMMARY:
==18514== in use at exit: 0 bytes in 0 blocks
==18514== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==18514==
==18514== All heap blocks were freed -- no leaks are possible
==18514==
==18514== For counts of detected and suppressed errors, rerun with: -v
==18514== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4)
Illegal instruction
However the instruction in question seems to be a valid SSE4.1
instruction, "insertps". The program runs fine without valgrind.
[Note that I didn't actually enable the use of SSE4.1 explicitly -- I
just compiled with "-march=native", and that automatically did so.]
The processor is an Intel "core2 duo". *** So to try the following test
you might need to be on a similar machine ***
The following is a small test program that causes g++-4.5 (version
"Debian 4.5-20100103-1") to generate the instruction. To repeat:
(0) Make sure you're on a machine that supports SSE4.1 instructions
(1) Make sure g++-4.5 (from experimental) is installed
(2) Compile the program with "make m4test"
(3) Run valgrind on it: "valgrind m4test"
(4) It should give the error output shown above
[Sorry I don't know if I can attach a tar file to a bug report, so I've
just put the files inline, with "===== FILENAME =====" before each file]
===== Makefile =====
CXX = g++-4.5
CXXFLAGS = -march=core2 -msse4.1 -O3 -ffast-math -fverbose-asm
m4test: m4test.o m4.o
$(CXX) -o $@ $(CXXFLAGS) $^
===== m4test.cc =====
#include "m4.h"
int main ()
{
Matrix4 x, y;
x = x * y;
return 0;
}
===== m4.h =====
class Matrix4
{
public:
Matrix4 ();
float &operator() (unsigned i, unsigned j) { return els[i][j]; }
const float &operator() (unsigned i, unsigned j) const { return els[i][j]; }
Matrix4 operator* (const Matrix4 &xform) const;
private:
float els[4][4];
};
===== m4.cc =====
#include "m4.h"
Matrix4::Matrix4 ()
{
els[0][0] = 1; els[0][1] = 0; els[0][2] = 0; els[0][3] = 0;
els[1][0] = 0; els[1][1] = 1; els[1][2] = 0; els[1][3] = 0;
els[2][0] = 0; els[2][1] = 0; els[2][2] = 1; els[2][3] = 0;
els[3][0] = 0; els[3][1] = 0; els[3][2] = 0; els[3][3] = 1;
}
Matrix4
Matrix4::operator* (const Matrix4 &xform) const
{
Matrix4 result;
for (unsigned i = 0; i < 4; i++)
for (unsigned j = 0; j < 4; j++)
result(i, j)
= (*this) (i, 0) * xform (0, j)
+ (*this) (i, 1) * xform (1, j)
+ (*this) (i, 2) * xform (2, j)
+ (*this) (i, 3) * xform (3, j);
return result;
}
===== END =====
Thanks,
-Miles
-- System Information:
Debian Release: squeeze/sid
APT prefers oldstable
APT policy: (500, 'oldstable'), (500, 'unstable'), (500, 'testing'), (500,
'stable'), (50, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.33-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=ja_JP.UTF-8, LC_CTYPE=ja_JP.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages valgrind depends on:
ii libc6 2.10.2-6 Embedded GNU C Library: Shared lib
ii libc6-dbg 2.10.2-6 Embedded GNU C Library: detached d
Versions of packages valgrind recommends:
ii gdb 7.1-1 The GNU Debugger
Versions of packages valgrind suggests:
pn alleyoop <none> (no description available)
pn kcachegrind <none> (no description available)
pn valkyrie <none> (no description available)
-- debconf-show failed
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]