地址0x5111715的未识别指令
valgrind: Unrecognised instruction at address 0x5111715
我有一个函数,看起来像这样-
std::string func()
{
std::string result;
...
auto seed = std::random_device()();
std::mt19937 gen(seed);
std::uniform_int_distribution<> dis(0, 61);
...
return result;
}
在各种编译器及其版本中都可以很好地编译,但在Ubuntu上仍然无法通过valgrind测试。我明确提到ubuntu是因为它能在我安装Arch Linux的机器上成功运行。
两个valgrind安装报告的版本都是valgrind-3.11.0
,唯一的区别是Arch Linux安装在我的机器上没有虚拟化,而Ubuntu测试是在DO/CI服务器上完成的,可能是在某种虚拟化下。但这有什么关系吗?
下面是valgrind运行的日志-
--- stderr ---
==13849== Memcheck, a memory error detector
==13849== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==13849== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==13849== Command: file/path/here
==13849==
vex amd64->IR: unhandled instruction bytes: 0xF 0xC7 0xF0 0x89 0x6 0xF 0x42 0xC1
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=0F
vex amd64->IR: PFX.66=0 PFX.F2=0 PFX.F3=0
==13849== valgrind: Unrecognised instruction at address 0x5111715.
==13849== at 0x5111715: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22)
==13849== by 0x51118B1: std::random_device::_M_getval() (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22)
==13849== by 0x4809FB: std::random_device::operator()() (random.h:1612)
==13849== by 0x47F0C2: isaac::deviceList::genId[abi:cxx11](unsigned int) (deviceList.cpp:21)
==13849== by 0x47F2A7: isaac::deviceList::place(isaac::deviceType, nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator>) (deviceList.cpp:38)
==13849== by 0x40D06E: DeviceList_place_Test::TestBody() (test.cpp:194)
==13849== by 0x45D5A7: void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2078)
==13849== by 0x4588D2: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2114)
==13849== by 0x43EBB3: testing::Test::Run() (gtest.cc:2151)
==13849== by 0x43F3F5: testing::TestInfo::Run() (gtest.cc:2326)
==13849== by 0x43FA52: testing::TestCase::Run() (gtest.cc:2444)
==13849== by 0x446911: testing::internal::UnitTestImpl::RunAllTests() (gtest.cc:4315)
==13849== Your program just tried to execute an instruction that Valgrind
==13849== did not recognise. There are two possible reasons for this.
==13849== 1. Your program has a bug and erroneously jumped to a non-code
==13849== location. If you are running Memcheck and you just saw a
==13849== warning about a bad jump, it's probably your program's fault.
==13849== 2. The instruction is legitimate but Valgrind doesn't handle it,
==13849== i.e. it's Valgrind's fault. If you think this is the case or
==13849== you are not sure, please let us know and we'll try to fix it.
==13849== Either way, Valgrind will now raise a SIGILL signal which will
==13849== probably kill your program.
==13849==
==13849== Process terminating with default action of signal 4 (SIGILL): dumping core
==13849== Illegal opcode at address 0x5111715
==13849== at 0x5111715: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22)
==13849== by 0x51118B1: std::random_device::_M_getval() (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22)
==13849== by 0x4809FB: std::random_device::operator()() (random.h:1612)
==13849== by 0x47F0C2: isaac::deviceList::genId[abi:cxx11](unsigned int) (deviceList.cpp:21)
==13849== by 0x47F2A7: isaac::deviceList::place(isaac::deviceType, nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator>) (deviceList.cpp:38)
==13849== by 0x40D06E: DeviceList_place_Test::TestBody() (test.cpp:194)
==13849== by 0x45D5A7: void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2078)
==13849== by 0x4588D2: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2114)
==13849== by 0x43EBB3: testing::Test::Run() (gtest.cc:2151)
==13849== by 0x43F3F5: testing::TestInfo::Run() (gtest.cc:2326)
==13849== by 0x43FA52: testing::TestCase::Run() (gtest.cc:2444)
==13849== by 0x446911: testing::internal::UnitTestImpl::RunAllTests() (gtest.cc:4315)
==13849==
==13849== HEAP SUMMARY:
==13849== in use at exit: 84,300 bytes in 108 blocks
==13849== total heap usage: 622 allocs, 514 frees, 530,112 bytes allocated
==13849==
==13849== LEAK SUMMARY:
==13849== definitely lost: 0 bytes in 0 blocks
==13849== indirectly lost: 0 bytes in 0 blocks
==13849== possibly lost: 0 bytes in 0 blocks
==13849== still reachable: 84,300 bytes in 108 blocks
==13849== suppressed: 0 bytes in 0 blocks
==13849== Rerun with --leak-check=full to see details of leaked memory
==13849==
==13849== For counts of detected and suppressed errors, rerun with: -v
==13849== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
-------
EDIT -我也尝试从官方源代码手动构建valgrind并安装它,但仍然产生相同的错误。
参见https://bugs.kde.org/show_bug.cgi?id=353370.
获取/编译svn最新版本应该可以解决这个问题。
如果没有,请在bugzilla上报告,因为3.12版本很快就会发布。由于
看起来你的Ubuntu系统有一个随机数字库,它使用RDRAND
指令(操作码0x0f 0xc7
),你的版本的Valgrind不识别。您的Arch系统显然使用了不同的实现,没有利用这条指令。
您可以通过重新编译ivy Bridge之前的CPU来解决这个问题。
相关文章:
- 使用C++库在Android项目中修改gradle中的cmake参数,用于插入指令的测试
- 提升 ASIO 无法识别计时器对象
- 无法编译 rtmidi 测试 cmidiin.cpp 文件, 非法指令
- 从udp接收帧对于人脸识别来说太慢
- 模板类无法识别友元运算符
- C++:对不存在的命名空间使用命名空间指令
- std::visit无法识别类型
- 函数名是c中该函数的第一条指令的地址吗
- 无法识别模板功能
- 我有两个类需要在同一 cpp 文件中相互引用,但第一个类无法识别第二个类类型的对象
- 错误:无效的预处理指令 #i 的意思是 #if?
- 如何在LLVM中dyn_cast以识别StoreInst?
- 组装指令中乘法的下部和上部是什么
- 从不同的附加依赖项中识别等同命名的函数
- C++出现控制台错误.我无法识别源代码的问题
- VSCode IntelliSense无法识别SDL框架的SDL_image扩展库
- Qt:"Q3DScatter"即使包含在内也无法识别
- OpenMP 与有序和关键指令并行
- 使用 qmake 成功编译 SSE 指令(但 SSE2 不被识别)
- 地址0x5111715的未识别指令