valgrind在dlopen中报告内存泄漏? [英] Memory leak reported by valgrind in dlopen?

查看:596
本文介绍了valgrind在dlopen中报告内存泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我用valgrind调试了一些应用程序,并且从dlopen收到非常奇怪的报告.

I've been debugging some app lately with valgrind, and I'm getting very weird reports from dlopen.

==1987== 32 bytes in 1 blocks are still reachable in loss record 1 of 2
==1987==    at 0x4C24477: calloc (vg_replace_malloc.c:418)
==1987==    by 0x570F31F: _dlerror_run (dlerror.c:142)
==1987==    by 0x570EEE0: dlopen@@GLIBC_2.2.5 (dlopen.c:88)
        <my call to dlopen>
==1987==
==1987== 264 bytes in 1 blocks are still reachable in loss record 2 of 2
==1987==    at 0x4C25153: malloc (vg_replace_malloc.c:195)
==1987==    by 0x400CD44: _dl_map_object_deps (dl-deps.c:506)
==1987==    by 0x4012DA2: dl_open_worker (dl-open.c:326)
==1987==    by 0x400E385: _dl_catch_error (dl-error.c:178)
==1987==    by 0x40126C6: _dl_open (dl-open.c:615)
==1987==    by 0x570EF65: dlopen_doit (dlopen.c:67)
==1987==    by 0x400E385: _dl_catch_error (dl-error.c:178)
==1987==    by 0x570F2AB: _dlerror_run (dlerror.c:164)
==1987==    by 0x570EEE0: dlopen@@GLIBC_2.2.5 (dlopen.c:88)
        <my call to dlopen>

这看起来像是为dlerror初始化的错误消息,但是在手册页上,它没有说明应如何清除.知道如何正确摆脱这种情况吗?

This looks like the error message that is initialized for dlerror, but looking at the man page, it doesn't say anything about how this should be cleared. Any idea how to correctly get rid of this?

推荐答案

能够使用一些"hello world"代码重现此问题,该代码甚至不调用已加载对象中的任何符号. http://pastebin.com/d690bea57

Was able to reproduce this issue with some 'hello world' code, which doesn't even call any symbols in the loaded object. http://pastebin.com/d690bea57

我认为这是libc或valgrind中的错误. 在Ubuntu 9.04和Scientific Linux 5.3(分别为20和32字节)上可重现.

I assume it's a bug in libc or valgrind. Reproducible on Ubuntu 9.04 and Scientific Linux 5.3 (20 and 32 bytes respectively).

编辑(由Calmarius编辑):

EDIT (by Calmarius):

此简单代码重现了该问题:

This trivial code reproduces the problem:

#include <dlfcn.h>

int main()
{
    void* handle = 0;

    handle = dlopen("libm.so", RTLD_NOW);
    dlclose(handle);    

    return 0;
}

使用此命令编译时:

gcc -Wl,--no-as-needed -g -o stuff  main.c -ldl -lpthread

即使最新的valgrind 3.11也可以在Ubuntu 14.04上重现此

Even the latest valgrind 3.11 can reproduce this on Ubuntu 14.04

已报告上游错误: https://bugs.kde.org/show_bug. cgi?id = 358980

这篇关于valgrind在dlopen中报告内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆