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

给你一囗甜甜゛ 提交于 2019-12-04 23:02:24

I got a bit curious since this is still broken in OpenSuse 12.x. I would have thought a bug originally reported in '09 or so would have been fixed by now. I guess nobody really uses sprof. (or maybe dl-open is so fragile that people are scared to touch it :-)

The issue boils down to the __RTLD_SPROF flag used as argument to dlopen. Take any simple program that calls dlopen, or that flag to the second arg and you get the same failed assertion. I used the sample program at the bottom of http://linux.die.net/man/3/dlopen as an example

handle = dlopen(argv[1], RTLD_LAZY | __RTLD_SPROF);

From what I can tell from a quick look at dl-open.c, this flags short circuits some of what dl_open does. So the r_flag specified in the assertion doesn't get set to RT_CONSISTENT.

If you're using Docker, there could be another explanation. In my case the profiling data was generated from a process running inside a Docker container, I tried running sprof from within the container and received the same error as described in the question. Running sprof from the host (instead of the container) solved it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!