2011-07-23 65 views
9

我在Valgrind得到了這個。C++/Valgrind REDIR

--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*)) 

有什麼擔心嗎?

+0

我會忽略這些警告。即使在最小的'int main(){}'程序中運行'valgrind',它們也會顯示出來。我不確定_why_究竟發生了什麼。順便說一下,在我的機器上'valgrind'會警告'index',而不是'strlen'。也許這取決於你的'libc'版本。 –

回答

13

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)

所以「規格」提供共享對象/函數名地址映射和「活性物質'代表映射本身。

主動運算:

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)

所以,畢竟這很可能是安全的假設:

  1. 重定向消息是正常的valgrind操作的一部分。
  2. 警告消息可能是相互衝突的規範模式的結果

引用(可能不適合在這種情況非常令人擔憂。):Valgrind manualValgrind 3.6.1 source

+2

請注意,當我使用valgrind時,我得到了這些:'valgrind --leak-check = full -v。/ your_program'。如果我刪除'-v',我不會收到它們。非常好,有這個問題和答案,布拉沃傢伙! :)我的意思是我很困惑發生了什麼事! – gsamaras