当我在非常简单的hdf5应用程序上使用valgrind时:
#include <stdio.h>
#include <hdf5.h>
int main() {
const char sFileName[] = "test1.qdf";
hid_t hFile = H5Fcreate(sFileName,H5F_acc_TRUNC,H5P_DEFAULT,H5P_DEFAULT);
if (hFile > 0) {
printf("File %s opened\n",sFileName);
H5Fclose(hFile);
} else {
printf("Couldn't create hFile [%s]\n",sFileName);
}
return 0;
}
我收到以下消息:
vex amd64->IR: unhandled instruction bytes: 0x62 0xF1 0xFE 0x8 0x6F 0x45 0x0 0xC5 0xF8 0x11
vex amd64->IR: REX=0 REX.W=0 REX.R=0 REX.X=0 REX.B=0
vex amd64->IR: VEX=0 VEX.L=0 VEX.nVVVV=0x0 ESC=NONE
vex amd64->IR: PFX.66=0 PFX.F2=0 PFX.F3=0
==34559== valgrind: Unrecognised instruction at address 0x4a50820.
==34559== at 0x4A50820: H5P_dup_prop (in /usr/lib64/libhdf5.so.103.1.0)
==34559== by 0x4A52465: H5P__do_prop_cb1.part.13 (in /usr/lib64/libhdf5.so.103.1.0)
==34559== by 0x4A51C01: H5P_create_id (in /usr/lib64/libhdf5.so.103.1.0)
==34559== by 0x4A52155: H5P__init_package (in /usr/lib64/libhdf5.so.103.1.0)
==34559== by 0x4A522C7: H5P_init (in /usr/lib64/libhdf5.so.103.1.0)
==34559== by 0x48C60ED: H5_init_library (in /usr/lib64/libhdf5.so.103.1.0)
==34559== by 0x48C690F: H5open (in /usr/lib64/libhdf5.so.103.1.0)
==34559== by 0x109213: main (h5simple.cpp:6)
==34559== Your program just tried to execute an instruction that Valgrind
==34559== did not recognise. There are two possible reasons for this.
==34559== 1. Your program has a bug and erroneously jumped to a non-code
==34559== location. If you are running Memcheck and you just saw a
==34559== warning about a bad jump,it's probably your program's fault.
==34559== 2. The instruction is legitimate but Valgrind doesn't handle it,==34559== i.e. it's Valgrind's fault. If you think this is the case or
==34559== you are not sure,please let us know and we'll try to fix it.
==34559== Either way,Valgrind will now raise a SIGILL signal which will
==34559== probably kill your program.
==34559==
==34559== Process terminating with default action of signal 4 (SIGILL)
==34559== Illegal opcode at address 0x4A50820
==34559== at 0x4A50820: H5P_dup_prop (in /usr/lib64/libhdf5.so.103.1.0)
==34559== by 0x4A52465: H5P__do_prop_cb1.part.13 (in /usr/lib64/libhdf5.so.103.1.0)
==34559== by 0x4A51C01: H5P_create_id (in /usr/lib64/libhdf5.so.103.1.0)
==34559== by 0x4A52155: H5P__init_package (in /usr/lib64/libhdf5.so.103.1.0)
==34559== by 0x4A522C7: H5P_init (in /usr/lib64/libhdf5.so.103.1.0)
==34559== by 0x48C60ED: H5_init_library (in /usr/lib64/libhdf5.so.103.1.0)
==34559== by 0x48C690F: H5open (in /usr/lib64/libhdf5.so.103.1.0)
==34559== by 0x109213: main (h5simple.cpp:6)
程序本身(即没有valgrind)运行时没有错误。
我尝试了valgrind版本3.13.0、3.14.0和3.15.0,以及gcc版本6.4.0、74.0、8.3.0和9.2.0。 对于这些valgrind版本和gcc版本的所有组合,valgrind都会给出“非法操作码”消息。
我正在使用的HDF5的版本为1.10.5(在gentoo上)。在我的系统上,我似乎无法安装旧版本的HDF5。
此非法操作码是否是HDF5的错误? 若要在我的HDF5应用程序上使用valgrind,我必须采取什么步骤?