草庐IT

gtest_valgrind

全部标签

c++ - Valgrind 报告标准库中未初始化的值 (vfprintf.c)

我有一个函数可以将vsnsprintf放入在堆栈上创建的对象的临时缓冲区中。在对象的构造函数中,我将缓冲区的第一个字符初始化为空。Valgrind提示在vfprintf.c的堆栈上创建了一个未初始化的值下面是完整的工作示例,后面是valgrind输出#include#include#includestructtmp_buf{tmp_buf(){*b=0;}mutablecharb[1024];};charconst*va_stack_str(constchar*format,va_listap,consttmp_buf&b=tmp_buf()){vsnprintf(b.b,sizeof

c++ - Valgrind 没有抛出错误,但并非所有堆分配都已被释放

这是我用Valgrind执行我的程序后得到的:1jscherman@jscherman:~/ClionProjects/algo2-t4-tries$g++Set.hpptests.cppDiccString.hpp&&valgrind--leak-check=yes--show-leak-kinds=all./a.out2==6823==Memcheck,amemoryerrordetector3==6823==Copyright(C)2002-2015,andGNUGPL'd,byJulianSewardetal.4==6823==UsingValgrind-3.11.0andLi

c# - gtest (C++) 和 nunit (C#) 中双重比较的区别

我已经将带有gtest测试的c++项目移植到带有nunit测试的c#项目。现在我遇到了浮点精度的问题。在nunit测试中我有问题(红色)Assert.AreEqual(0.7,7*0.1);在gtest测试中我有:ASSERT_DOUBLE_EQ(0.7,7*0.1);没问题(绿色)现在的问题是为什么??? 最佳答案 GoogleTest的ASSERT_DOUBLE_EQ()验证实际值是否在预期值的4个ULP之内(更多信息请参见https://github.com/google/googletest/blob/main/docs/a

c++ - 试图理解 valgrind 输出

这是valgrind的输出..Conditionaljumpormovedependsonuninitialisedvalue(s)inRingsWidget::UpdateSeekBar()inringswidget.cpp:5141:RingsWidget::UpdateSeekBar()inringswidget.cpp:5142:RingsWidget::UpdateRings()inringswidget.cpp:1383:RingsWidget::qt_static_metacall(QObject*,QMetaObject::Call,int,void**)in/medi

c++ - Gtest : Expected Class-Name Before '{'

我正在尝试将Gtest下的测试用例转换为使用测试夹具,以便在添加更多测试时可以使用通用设置。但是,这会导致错误:test_integrate.cc:4:47:error:expectedclass-namebefore'{'tokenclassIntegratorTest:public::testing::test{这种失败是我无法理解的,因为根据我的经验,它通常是由循环导入引起的,并且导入与工作代码相比没有变化。完整代码如下:#include"gtest/gtest.h"#include"utils/integrate.hpp"classIntegratorTest:public::

c++ - Valgrind 下 Mac OS 上的 std::thread.join() SIGSEGV

以下简单代码(C++11)将仅在MacOS和Linux上运行:#include#include#includevoidthreadFunction(){for(intcc=0;cc但是,在Valgrind中包装执行:valgrind--leak-check=full--show-reachable=no--track-fds=yes--error-exitcode=1--track-origins=yes./theexecutable...它现在可以在Linux上运行,但不能在MacOSX上运行,失败:==47544==Processterminatingwithdefaultacti

c++ - Valgrind 未检测到危险的释放内存

我正在学习valgrind框架,我决定在我自己的小测试用例上运行它。这是以下程序,它强制从堆中删除额外的对象(我在AMD64/LINUX上运行它):#includeusingnamespacestd;structFoo{Foo(){cout(ar)-2)=4;delete[]ar;return0;}但是valgrind的执行结果让我很困惑:$valgrind--leak-check=full./a.out-v==17649==Memcheck,amemoryerrordetector==17649==Copyright(C)2002-2017,andGNUGPL'd,byJulianS

c++ - std::map 中的 std::string 导致 Valgrind 内存泄漏

这是Valgrind的输出:==6519==at0x4C25885:operatornew(unsignedlong)(vg_replace_malloc.c:319)==6519==by0x4EE65D8:std::string::_Rep::_S_create(unsignedlong,unsignedlong,std::allocatorconst&)(new_allocator.h:104)==6519==by0x4EE7CE0:char*std::string::_S_construct(charconst*,charconst*,std::allocatorconst&,s

c++ - 是否可以在部分代码上运行 valgrind?

我在相当大的系统的已知部分中发生了内存泄漏。我想全速运行直到该部分代码,在该部分运行valgrindmemcheck,并在该部分末尾收集valgrindmemcheck报告而不进一步完成运行。这可能吗? 最佳答案 不是memcheck,不。根据valgrindFAQ,callgrind是目前唯一支持这个的valgrind组件:5.4.IsitpossibletoattachValgrindtoaprogramthatisalreadyrunning?No.TheenvironmentthatValgrindprovidesforru

c++ - 与柯南一起安装的 GTest : undefined reference

我尝试使用通过柯南安装的gtest,但最终出现undefinedreference链接器错误。这个问题或多或少是对thisstackoverflowquestion的跟进。.但我认为提供的例子太简单了。我使用gcc6.3在最新的archlinuxx64下编译。C++版本会不会有些不匹配?或者您对如何解决问题有任何其他想法吗?我将在下面提供我的源代码:目录树:tree.├──CMakeLists.txt├──conanfile.txt└──main.cpp主要.cpp:#include#includeclassTestFixture:public::testing::Test{prote