我有一个看起来像这样的函数 -
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)
-------
编辑 - 我也尝试过从官方来源手动构建 valgrind 并安装它,但仍然会产生相同的错误。
最佳答案
参见 https://bugs.kde.org/show_bug.cgi?id=353370 .
获取/编译最新的 svn 版本应该可以解决这个问题。
如果没有,请在 bugzilla 上报告,因为 3.12 版本即将发布。 谢谢
关于c++ - valgrind:地址 0x5111715 处无法识别的指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39673469/
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在
我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r
我的瘦服务器配置了nginx,我的ROR应用程序正在它们上运行。在我发布代码更新时运行thinrestart会给我的应用程序带来一些停机时间。我试图弄清楚如何优雅地重启正在运行的Thin实例,但找不到好的解决方案。有没有人能做到这一点? 最佳答案 #Restartjustthethinserverdescribedbythatconfigsudothin-C/etc/thin/mysite.ymlrestartNginx将继续运行并代理请求。如果您将Nginx设置为使用多个上游服务器,例如server{listen80;server
我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e
我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳
我在pry中定义了一个函数:to_s,但我无法调用它。这个方法去哪里了,怎么调用?pry(main)>defto_spry(main)*'hello'pry(main)*endpry(main)>to_s=>"main"我的ruby版本是2.1.2看了一些答案和搜索后,我认为我得到了正确的答案:这个方法用在什么地方?在irb或pry中定义方法时,会转到Object.instance_methods[1]pry(main)>defto_s[1]pry(main)*'hello'[1]pry(main)*end=>:to_s[2]pry(main)>defhello[2]pry(main)
我使用的是Firefox版本36.0.1和Selenium-Webdrivergem版本2.45.0。我能够创建Firefox实例,但无法使用脚本继续进行进一步的操作无法在60秒内获得稳定的Firefox连接(127.0.0.1:7055)错误。有人能帮帮我吗? 最佳答案 我遇到了同样的问题。降级到firefoxv33后一切正常。您可以找到旧版本here 关于ruby-无法在60秒内获得稳定的Firefox连接(127.0.0.1:7055),我们在StackOverflow上找到一个类
当我尝试安装Ruby时遇到此错误。我试过查看this和this但无济于事➜~brewinstallrubyWarning:YouareusingOSX10.12.Wedonotprovidesupportforthispre-releaseversion.Youmayencounterbuildfailuresorotherbreakages.Pleasecreatepull-requestsinsteadoffilingissues.==>Installingdependenciesforruby:readline,libyaml,makedepend==>Installingrub
我有一个存储主机名的Ruby数组server_names。如果我打印出来,它看起来像这样:["hostname.abc.com","hostname2.abc.com","hostname3.abc.com"]相当标准。我想要做的是获取这些服务器的IP(可能将它们存储在另一个变量中)。看起来IPSocket类可以做到这一点,但我不确定如何使用IPSocket类遍历它。如果它只是尝试像这样打印出IP:server_names.eachdo|name|IPSocket::getaddress(name)pnameend它提示我没有提供服务器名称。这是语法问题还是我没有正确使用类?输出:ge