我有一段代碼看起來像這樣:什麼可能導致dynamic_cast崩潰?
TAxis *axis = 0;
if (dynamic_cast<MonitorObjectH1C*>(obj))
axis = (dynamic_cast<MonitorObjectH1C*>(obj))->GetXaxis();
有時它崩潰:
Thread 1 (Thread -1208658240 (LWP 11400)):
#0 0x0019e7a2 in _dl_sysinfo_int80() from /lib/ld-linux.so.2
#1 0x048c67fb in __waitpid_nocancel() from /lib/tls/libc.so.6
#2 0x04870649 in do_system() from /lib/tls/libc.so.6
#3 0x048709c1 in system() from /lib/tls/libc.so.6
#4 0x001848bd in system() from /lib/tls/libpthread.so.0
#5 0x0117a5bb in TUnixSystem::Exec() from /opt/root/lib/libCore.so.5.21
#6 0x01180045 in TUnixSystem::StackTrace() from /opt/root/lib/libCore.so.5.21
#7 0x0117cc8a in TUnixSystem::DispatchSignals()
from /opt/root/lib/libCore.so.5.21
#8 0x0117cd18 in SigHandler() from /opt/root/lib/libCore.so.5.21
#9 0x0117bf5d in sighandler() from /opt/root/lib/libCore.so.5.21
#10 <signal handler called>
#11 0x0533ddf4 in __dynamic_cast() from /usr/lib/libstdc++.so.6
我不知道爲什麼它崩潰。 obj不爲空(如果它不是問題,是嗎?)。
什麼可能是動態演員陣容崩潰的原因?
如果它不能轉換,它應該只返回NULL否?
好直覺!另一個線程釋放了'obj'。 – Barth 2008-11-11 07:39:54