c++ 内存泄漏、死锁之valgrind定位问题

本文介绍了Linux下开源的内存泄漏检测工具valgrind,包括其核心组件、常用的memcheck和Helgrind工具的使用,以及如何通过valgrind检测内存泄漏和多线程程序中的竞争问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

c++系列文章目录



前言

该篇主要介绍开源的内存泄漏工具 valgrind,valgrind 是一套 Linux 下,开放源代码的动态调试工具集合,能够检测内存管理错误、线程 BUG 等,valgrind 由内核(core)以及基于内核的其他调试工具组成。内核类似于一个框(framework),它模拟了一个 CPU 环境,并提供服务给其他工具;而其他工具则类似于插件 (plug-in),利用内核提供的服务完成各种特定的内存调试任务。


一、valgrind 是什么?

Valgrind是一套Linux下,开放源代码(GPL V2)的仿真调试工具的集合。Valgrind由内核(core)以及基于内核的其他调试工具组成。内核类似于一个框架(framework),它模拟了一个CPU环境,并提供服务给其他工具;而其他工具则类似于插件 (plug-in),利用内核提供的服务完成各种特定的内存调试任务。

valgrind包括的工具如下:
memcheck,这是valgrind应用最广泛的工具,一个重量级的内存检查器,能够发现开发中绝大多数内存错误使用情况,比如:使用未初始化的内存,使用已经释放了的内存,内存访问越界等。
callgrind,主要用来检查程序中函数调用过程中出现的问题。
cachegrind,主要用来检查程序中缓存使用出现的问题。
helgrind,主要用来检查多线程程序中出现的竞争问题。
massif,主要用来检查程序中堆栈使用中出现的问题。
extension,可以利用core提供的功能,自己编写特定的内存调试工具。

valgrind有很多功能,本文仅仅介绍了一种最基本的应用。

二、valgrind环境搭建

1.环境安装

wget https://sourceware.org/pub/valgrind/valgrind-3.2.1.tar.bz2 --no-check-certificate
解压
tar -jxvf valgrind-3.14.0.tar.bz2 
安装目录
cd valgrind-3.14.0
./configure --prefix=/home/user1/valgrind
make
make install
//设置环境变量
vim ~/.bashrc
export PATH=$PATH:~/valgrind/bin/
source ~/.bashrc

或者安装通过
yum install valgrind

如下方式来观察内存泄漏
valgrind --tool=memcheck --leak-check=full --error-limit=no --num-callers=50 --show-reachable=yes --log-file=./valgrind_report.log ./mytest

--tool=memcheck : 使用内存检测的工具
--leak-check=full : 有设置这个选项时,当被测程序结束时查找内存泄露。设置为summary,Valgrind会统计有多少内存泄露发生,若设置为full、yes,Valgrind会给出每一个独立的泄露的详细信息
--error-limit=no:如果错误太多要停止显示新的错误的选项
--num-callers=50:这个值默认是12,最高是50。表示显示多少层的堆栈,设置越高会使Valgrind运行越慢而且使用更多的内存,但是在嵌套调用层次比较高的程序中非常实用
--log-file=/home/davit/valgrind_report.log: 指定检测结果报告的存放路径和文件名
./xxxx: 执行被测可执行文件
--show-reachable=yes

三、valgribd的memcheck 使用步骤

1.Memcheck
最常用的工具,用来检测程序中出现的内存问题,所有对内存的读写都会被检测到,一切对malloc()/free()/new/delete的调用都会被捕获。所以,它能检测以下问题:

1.对未初始化内存的使用;
2.读/写释放后的内存块;
3.读/写超出malloc分配的内存块;
4.读/写不适当的栈中内存块;
5.内存泄漏,指向一块内存的指针永远丢失;
6.不正确的malloc/free或new/delete匹配;
7.memcpy()相关函数中的dst和src指针重叠。

#include <iostream> 
#include <unistd.h> 
#include <string.h> 
#include <iostream>
#include <fstream>
int fun(char* pData,int size)
{
    const char *recordpath = "/opt/eDisk/davit.test"; 
    std::ofstream outfile;
    outfile.open(recordpath, std::ios_base::out|std::ios_base::app);
    outfile.write((const char*) pData, size);
    return 0;
}

int memLeakage()
{
    char *pMemory = new char [1024];
    memset(pMemory,1,1024); 
    fun(pMemory,1024);
}
int main(int argc, char* argv[]) 
{
    memLeakage();
    sleep(60);
    return 0;
}

编译:
g++ test.cpp -o mytest -std=c++11 -g -fno-elide-constructors
内存泄漏检测:
valgrind --tool=memcheck --leak-check=full --error-limit=no --num-callers=50 --show-reachable=yes --log-file=./valgrind_report.log ./mytest

==29711== Memcheck, a memory error detector
==29711== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==29711== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==29711== Command: ./mytest
==29711== Parent PID: 17468
==29711== 
==29711== 
==29711== Process terminating with default action of signal 2 (SIGINT)
==29711==    at 0x571C9E0: __nanosleep_nocancel (in /usr/lib64/libc-2.17.so)
==29711==    by 0x571C893: sleep (in /usr/lib64/libc-2.17.so)
==29711==    by 0x40124B: main (test.cpp:339)
==29711== 
==29711== HEAP SUMMARY:
==29711==     in use at exit: 1,024 bytes in 1 blocks
==29711==   total heap usage: 3 allocs, 2 frees, 9,784 bytes allocated
==29711== 
==29711== 1,024 bytes in 1 blocks are definitely lost in loss record 1 of 1
==29711==    at 0x4C2AC38: operator new[](unsigned long) (vg_replace_malloc.c:433)
==29711==    by 0x401200: memLeakage() (test.cpp:331)
==29711==    by 0x401241: main (test.cpp:338)
==29711== 
==29711== LEAK SUMMARY:
==29711==    definitely lost: 1,024 bytes in 1 blocks
==29711==    indirectly lost: 0 bytes in 0 blocks
==29711==      possibly lost: 0 bytes in 0 blocks
==29711==    still reachable: 0 bytes in 0 blocks
==29711==         suppressed: 0 bytes in 0 blocks
==29711== 
==29711== For lists of detected and suppressed errors, rerun with: -s
==29711== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

通过检测报告,本代码种存在一个内存泄漏的问题,即函数memLeakge存在内存泄漏,这样就很容易判断问题了。
在这里插入图片描述

四、valgrind的Helgrind使用步骤

Helgrind
它主要用来检查多线程程序中出现的竞争问题。Helgrind寻找内存中被多个线程访问,而又没有一贯加锁的区域,
这些区域往往是线程之间失去同步的地方,而且会导致难以发掘的错误。Helgrind实现了名为“Eraser”的竞争检测算法,并做了进一步改进,减少了报告错误的次数。不过,Helgrind仍然处于实验阶段。

#include <thread>
#include <mutex>
#include <stdio.h>
#include <unistd.h> 
#include <iostream>
#include <memory>
#include <string.h>

std::mutex _ma;
std::mutex _mb;

void threadAB()
{
    std::cout<< "in threadAB" <<std::endl;
    std::unique_lock<std::mutex> locka(_ma);
    std::this_thread::sleep_for(std::chrono::milliseconds(100));
    std::unique_lock<std::mutex> lockb(_mb);
    std::cout<< "out threadAB2" <<std::endl;
}

void threadBA()
{
    std::cout<< "in threadBA" <<std::endl;
    std::unique_lock<std::mutex> lockb(_mb);
    //std::this_thread::sleep_for(std::chrono::milliseconds(1));
    std::unique_lock<std::mutex> locka(_ma);
    std::cout<< "out threadBA2" <<std::endl;
}
void test2()
{
    auto t1 = std::thread(threadAB);
    auto t2 = std::thread(threadBA);
    t1.join();
    t2.join();          
}

int main()
{
    test2();
    std::cout<< "helloworld" <<std::endl;
    return 0;
}

编译:
g++ -g test.cpp -lpthread -std=c++11 -o MyLesson
内存泄漏检测:
valgrind --tool=helgrind --log-file=./valgrind_report.log ./test

==9131== Helgrind, a thread error detector
==9131== Copyright (C) 2007-2017, and GNU GPL'd, by OpenWorks LLP et al.
==9131== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==9131== Command: ./test
==9131== Parent PID: 9074
==9131== 
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- Ignoring non-Dwarf2/3/4 block in .debug_info
--9131-- WARNING: Serious error when reading debug info
--9131-- When reading debug info from /usr/lib64/libstdc++.so.6.0.30:
--9131-- parse_CU_Header: is neither DWARF2 nor DWARF3 nor DWARF4
==9131== ---Thread-Announcement------------------------------------------
==9131== 
==9131== Thread #3 was created
==9131==    at 0x5A8492E: clone (in /usr/lib64/libc-2.17.so)
==9131==    by 0x4E43059: do_clone.constprop.4 (in /usr/lib64/libpthread-2.17.so)
==9131==    by 0x4E44569: pthread_create@@GLIBC_2.2.5 (in /usr/lib64/libpthread-2.17.so)
==9131==    by 0x4C30CEA: pthread_create_WRK (hg_intercepts.c:427)
==9131==    by 0x4C31DC8: pthread_create@* (hg_intercepts.c:460)
==9131==    by 0x512AC2E: std::thread::_M_start_thread(std::shared_ptr<std::thread::_Impl_base>, void (*)()) (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x512ACFF: std::thread::_M_start_thread(std::shared_ptr<std::thread::_Impl_base>) (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x4019A1: std::thread::thread<void (&)()>(void (&)()) (thread:135)
==9131==    by 0x4012C9: test2() (test.cpp:32)
==9131==    by 0x401336: main (test.cpp:39)
==9131== 
==9131== ---Thread-Announcement------------------------------------------
==9131== 
==9131== Thread #2 was created
==9131==    at 0x5A8492E: clone (in /usr/lib64/libc-2.17.so)
==9131==    by 0x4E43059: do_clone.constprop.4 (in /usr/lib64/libpthread-2.17.so)
==9131==    by 0x4E44569: pthread_create@@GLIBC_2.2.5 (in /usr/lib64/libpthread-2.17.so)
==9131==    by 0x4C30CEA: pthread_create_WRK (hg_intercepts.c:427)
==9131==    by 0x4C31DC8: pthread_create@* (hg_intercepts.c:460)
==9131==    by 0x512AC2E: std::thread::_M_start_thread(std::shared_ptr<std::thread::_Impl_base>, void (*)()) (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x512ACFF: std::thread::_M_start_thread(std::shared_ptr<std::thread::_Impl_base>) (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x4019A1: std::thread::thread<void (&)()>(void (&)()) (thread:135)
==9131==    by 0x4012B8: test2() (test.cpp:31)
==9131==    by 0x401336: main (test.cpp:39)
==9131== 
==9131== ----------------------------------------------------------------
==9131== 
==9131== Possible data race during read of size 8 at 0x605118 by thread #3
==9131== Locks held: none
==9131==    at 0x518426E: std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long) (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x51846D6: std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x401207: threadBA() (test.cpp:23)
==9131==    by 0x402A40: void std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>) (functional:1732)
==9131==    by 0x40299A: std::_Bind_simple<void (*())()>::operator()() (functional:1720)
==9131==    by 0x402933: std::thread::_Impl<std::_Bind_simple<void (*())()> >::_M_run() (thread:115)
==9131==    by 0x512AB07: execute_native_thread_routine_compat (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x4C30EDE: mythread_wrapper (hg_intercepts.c:389)
==9131==    by 0x4E43EA4: start_thread (in /usr/lib64/libpthread-2.17.so)
==9131==    by 0x5A8496C: clone (in /usr/lib64/libc-2.17.so)
==9131== 
==9131== This conflicts with a previous write of size 8 by thread #2
==9131== Locks held: none
==9131==    at 0x5184330: std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long) (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x51846D6: std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x401132: threadAB() (test.cpp:14)
==9131==    by 0x402A40: void std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>) (functional:1732)
==9131==    by 0x40299A: std::_Bind_simple<void (*())()>::operator()() (functional:1720)
==9131==    by 0x402933: std::thread::_Impl<std::_Bind_simple<void (*())()> >::_M_run() (thread:115)
==9131==    by 0x512AB07: execute_native_thread_routine_compat (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x4C30EDE: mythread_wrapper (hg_intercepts.c:389)
==9131==  Address 0x605118 is 24 bytes inside data symbol "_ZSt4cout@@GLIBCXX_3.4"
==9131== 
==9131== ----------------------------------------------------------------
==9131== 
==9131== Possible data race during write of size 8 at 0x605118 by thread #3
==9131== Locks held: none
==9131==    at 0x5184330: std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long) (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x51846D6: std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x401207: threadBA() (test.cpp:23)
==9131==    by 0x402A40: void std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>) (functional:1732)
==9131==    by 0x40299A: std::_Bind_simple<void (*())()>::operator()() (functional:1720)
==9131==    by 0x402933: std::thread::_Impl<std::_Bind_simple<void (*())()> >::_M_run() (thread:115)
==9131==    by 0x512AB07: execute_native_thread_routine_compat (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x4C30EDE: mythread_wrapper (hg_intercepts.c:389)
==9131==    by 0x4E43EA4: start_thread (in /usr/lib64/libpthread-2.17.so)
==9131==    by 0x5A8496C: clone (in /usr/lib64/libc-2.17.so)
==9131== 
==9131== This conflicts with a previous write of size 8 by thread #2
==9131== Locks held: none
==9131==    at 0x5184330: std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long) (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x51846D6: std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x401132: threadAB() (test.cpp:14)
==9131==    by 0x402A40: void std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>) (functional:1732)
==9131==    by 0x40299A: std::_Bind_simple<void (*())()>::operator()() (functional:1720)
==9131==    by 0x402933: std::thread::_Impl<std::_Bind_simple<void (*())()> >::_M_run() (thread:115)
==9131==    by 0x512AB07: execute_native_thread_routine_compat (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x4C30EDE: mythread_wrapper (hg_intercepts.c:389)
==9131==  Address 0x605118 is 24 bytes inside data symbol "_ZSt4cout@@GLIBCXX_3.4"
==9131== 
==9131== ----------------------------------------------------------------
==9131== 
==9131== Possible data race during read of size 1 at 0x546C898 by thread #3
==9131== Locks held: none
==9131==    at 0x518406A: std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&) (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x401214: threadBA() (test.cpp:23)
==9131==    by 0x402A40: void std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>) (functional:1732)
==9131==    by 0x40299A: std::_Bind_simple<void (*())()>::operator()() (functional:1720)
==9131==    by 0x402933: std::thread::_Impl<std::_Bind_simple<void (*())()> >::_M_run() (thread:115)
==9131==    by 0x512AB07: execute_native_thread_routine_compat (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x4C30EDE: mythread_wrapper (hg_intercepts.c:389)
==9131==    by 0x4E43EA4: start_thread (in /usr/lib64/libpthread-2.17.so)
==9131==    by 0x5A8496C: clone (in /usr/lib64/libc-2.17.so)
==9131== 
==9131== This conflicts with a previous write of size 1 by thread #2
==9131== Locks held: none
==9131==    at 0x5125BFC: std::ctype<char>::_M_widen_init() const (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x5184097: std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&) (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x40113F: threadAB() (test.cpp:14)
==9131==    by 0x402A40: void std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>) (functional:1732)
==9131==    by 0x40299A: std::_Bind_simple<void (*())()>::operator()() (functional:1720)
==9131==    by 0x402933: std::thread::_Impl<std::_Bind_simple<void (*())()> >::_M_run() (thread:115)
==9131==    by 0x512AB07: execute_native_thread_routine_compat (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x4C30EDE: mythread_wrapper (hg_intercepts.c:389)
==9131==  Address 0x546c898 is 56 bytes inside data symbol "_ZN12_GLOBAL__N_17ctype_cE"
==9131== 
==9131== ----------------------------------------------------------------
==9131== 
==9131== Possible data race during read of size 1 at 0x546C8A3 by thread #3
==9131== Locks held: none
==9131==    at 0x5184073: std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&) (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x401214: threadBA() (test.cpp:23)
==9131==    by 0x402A40: void std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>) (functional:1732)
==9131==    by 0x40299A: std::_Bind_simple<void (*())()>::operator()() (functional:1720)
==9131==    by 0x402933: std::thread::_Impl<std::_Bind_simple<void (*())()> >::_M_run() (thread:115)
==9131==    by 0x512AB07: execute_native_thread_routine_compat (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x4C30EDE: mythread_wrapper (hg_intercepts.c:389)
==9131==    by 0x4E43EA4: start_thread (in /usr/lib64/libpthread-2.17.so)
==9131==    by 0x5A8496C: clone (in /usr/lib64/libc-2.17.so)
==9131== 
==9131== This conflicts with a previous write of size 8 by thread #2
==9131== Locks held: none
==9131==    at 0x5125B21: std::ctype<char>::_M_widen_init() const (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x5184097: std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&) (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x40113F: threadAB() (test.cpp:14)
==9131==    by 0x402A40: void std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>) (functional:1732)
==9131==    by 0x40299A: std::_Bind_simple<void (*())()>::operator()() (functional:1720)
==9131==    by 0x402933: std::thread::_Impl<std::_Bind_simple<void (*())()> >::_M_run() (thread:115)
==9131==    by 0x512AB07: execute_native_thread_routine_compat (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x4C30EDE: mythread_wrapper (hg_intercepts.c:389)
==9131==  Address 0x546c8a3 is 67 bytes inside data symbol "_ZN12_GLOBAL__N_17ctype_cE"
==9131== 
==9131== 
==9131== Process terminating with default action of signal 2 (SIGINT)
==9131==    at 0x4E45017: pthread_join (in /usr/lib64/libpthread-2.17.so)
==9131==    by 0x4C2DF81: pthread_join_WRK (hg_intercepts.c:553)
==9131==    by 0x4C31DD3: pthread_join (hg_intercepts.c:572)
==9131==    by 0x512A9F2: std::thread::join() (in /usr/lib64/libstdc++.so.6.0.30)
==9131==    by 0x4012D5: test2() (test.cpp:33)
==9131==    by 0x401336: main (test.cpp:39)
==9131== ----------------------------------------------------------------
==9131== 
==9131== Thread #3: Exiting thread still holds 1 lock
==9131==    at 0x4E4A54D: __lll_lock_wait (in /usr/lib64/libpthread-2.17.so)
==9131==    by 0x4E45E9A: _L_lock_883 (in /usr/lib64/libpthread-2.17.so)
==9131==    by 0x4E45D66: pthread_mutex_lock (in /usr/lib64/libpthread-2.17.so)
==9131==    by 0x4C2E2EB: mutex_lock_WRK (hg_intercepts.c:902)
==9131==    by 0x4C321AD: pthread_mutex_lock (hg_intercepts.c:925)
==9131==    by 0x40105B: __gthread_mutex_lock(pthread_mutex_t*) (gthr-default.h:748)
==9131==    by 0x4015BF: std::mutex::lock() (mutex:134)
==9131==    by 0x401AAA: std::unique_lock<std::mutex>::lock() (mutex:511)
==9131==    by 0x401666: std::unique_lock<std::mutex>::unique_lock(std::mutex&) (mutex:443)
==9131==    by 0x401236: threadBA() (test.cpp:26)
==9131==    by 0x402A40: void std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>) (functional:1732)
==9131==    by 0x40299A: std::_Bind_simple<void (*())()>::operator()() (functional:1720)
==9131== 
==9131== ----------------------------------------------------------------
==9131== 
==9131== Thread #2: Exiting thread still holds 1 lock
==9131==    at 0x4E4A54D: __lll_lock_wait (in /usr/lib64/libpthread-2.17.so)
==9131==    by 0x4E45E9A: _L_lock_883 (in /usr/lib64/libpthread-2.17.so)
==9131==    by 0x4E45D66: pthread_mutex_lock (in /usr/lib64/libpthread-2.17.so)
==9131==    by 0x4C2E2EB: mutex_lock_WRK (hg_intercepts.c:902)
==9131==    by 0x4C321AD: pthread_mutex_lock (hg_intercepts.c:925)
==9131==    by 0x40105B: __gthread_mutex_lock(pthread_mutex_t*) (gthr-default.h:748)
==9131==    by 0x4015BF: std::mutex::lock() (mutex:134)
==9131==    by 0x401AAA: std::unique_lock<std::mutex>::lock() (mutex:511)
==9131==    by 0x401666: std::unique_lock<std::mutex>::unique_lock(std::mutex&) (mutex:443)
==9131==    by 0x401187: threadAB() (test.cpp:17)
==9131==    by 0x402A40: void std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>) (functional:1732)
==9131==    by 0x40299A: std::_Bind_simple<void (*())()>::operator()() (functional:1720)
==9131== 
==9131== 
==9131== Use --history-level=approx or =none to gain increased speed, at
==9131== the cost of reduced accuracy of conflicting-access information
==9131== For lists of detected and suppressed errors, rerun with: -s
==9131== ERROR SUMMARY: 6 errors from 6 contexts (suppressed: 34 from 24)

在这里插入图片描述

总结

本文就是抛砖引玉,希望你能够更好的使用valgrind,它能够帮你解决很多问题。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

c+猿辅导

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值