我在Valgrind得到这个。
--24101-- REDIR: 0xbb20580 (operator delete(void*)) redirected to 0x93b7d48 (operator delete(void*))
--24101-- REDIR: 0xbb22580 (operator new[](unsigned long)) redirected to 0x93b88b7 (operator new[](unsigned long))
==24101== WARNING: new redirection conflicts with existing -- ignoring it
--24101-- new: 0x15632010 (__GI_strlen ) R-> 0x093b96b0 strlen
--24101-- REDIR: 0xbb205c0 (operator delete[](void*)) redirected to 0x93b79c4 (operator delete[](void*))
有什么顾虑吗?
Valgrind的神奇之处在于它如何拦截/重定向函数调用以跟踪世界状态。
据我了解,重定向是使用共享对象/函数名称模式实现的,当匹配“重定向”调用新地址时。检查valgrind源代码,我们发现了'重定向器'的概念:
The redirector holds two pieces of state:
Specs - a set of (soname pattern, fnname pattern) -> redir addr
Active - a set of orig addr -> (bool, redir addr)
(m_redir.c第104行)
所以'Specs'提供共享对象/函数名称来映射映射,'Actives'代表映射本身。
主动计算:
Active = empty
for spec in Specs {
sopatt = spec.soname pattern
fnpatt = spec.fnname pattern
redir = spec.redir addr
for so matching sopatt in SyminfoState {
for fn matching fnpatt in fnnames_of(so) {
&fn -> redir is added to Active
}
}
}
(m_redir.c第120行)
这里也提到了“冲突重定向”的想法:
Clearly we must impose the requirement that domain(Active) contains
no duplicates. The difficulty is how to constrain Specs enough to
avoid getting into that situation. It's easy to write specs which
could cause conflicting bindings in Active, eg:
(libpthread.so, pthread_mutex_lock) -> a1
(libpthread.so, pthread_*) -> a2
for a1 != a2. Or even hairier:
(libpthread.so, pthread_mutex_*) -> a1
(libpthread.so, pthread_*_lock) -> a2
(m_redir.c第152行)
为了利益,这里是您生成警告的地方:
old = VG_(OSetGen_Lookup)( activeSet, &act.from_addr );
if (old) {
/* Dodgy. Conflicting binding. */
vg_assert(old->from_addr == act.from_addr);
if (old->to_addr != act.to_addr) {
/* we have to ignore it -- otherwise activeSet would contain
conflicting bindings. */
what = "new redirection conflicts with existing -- ignoring it";
goto bad;
}
(m_redir.c第664行)
因此,在所有这些之后,可以安全地假设:
- 重定向消息是正常valgrind操作的一部分。
- 警告消息可能是规范模式冲突的结果(在这种情况下可能不是引起关注的重要原因。)
参考文献: Valgrind手册, Valgrind 3.6.1来源