What is causing sprof to complain about "inconsistency detected by ld.so"?

Edw*_*ard 16 shared-libraries libc ld dlopen sprof

I'm trying to use sprof to profile some software (ossim) where almost all the code is in a shared library. I've generated a profiling file, but when I run sprof, I get the following error:

> sprof /home/eca7215/usr/lib/libossim.so.1 libossim.so.1.profile -p > log
Inconsistency detected by ld.so: dl-open.c: 612: _dl_open: Assertion `_dl_debug_initialize (0, args.nsid)->r_state == RT_CONSISTENT' failed!
Run Code Online (Sandbox Code Playgroud)

The instructions I was following said that I needed libc version at least 2.5-34, I have libc version 2.12.2 (Gentoo, kernel 2.6.36-r5).

I can't find any explanation as to what the error means or (more interestingly) how to fix it, the only half-relevant google results are for a bug in an old version of Skype.

小智 6

我有点好奇,因为这在OpenSuse 12.x中仍然存在.我原本以为在09年左右报道的一个错误现在已经解决了.我猜没有人真正使用sprof.(或者dl-open是如此脆弱,以至于人们害怕触摸它:-)

问题归结为__RTLD_SPROF标志,用作dlopen的参数.将任何调用dlopen或该标志的简单程序带到第二个arg,你得到相同的失败断言.我使用了http://linux.die.net/man/3/dlopen底部的示例程序作为示例

handle = dlopen(argv[1], RTLD_LAZY | __RTLD_SPROF);
Run Code Online (Sandbox Code Playgroud)

从我快速查看dl-open.c可以看出,这标志着dl_open所做的一些短路.因此断言中指定的r_flag不会设置为RT_CONSISTENT.

  • 这有点烦人.很多人建议使用oprofile,但到目前为止我还没有能够构建它.您对如何配置共享库有什么建议吗? (2认同)