In the following code, I'm seeing a segfault at the line that says signaling_thread_->Send(this, id, data);
, which is being called from the destructor of the PeerConnectionProxy class.
bool PeerConnectionProxy::Send(uint32 id, talk_base::MessageData* data) {
if (!signaling_thread_)
return false;
signaling_thread_->Send(this, id, data);
return true;
}
Running in gdb, I get the segfault and this stack trace as soon as I do (gdb) step
to that line:
Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
(gdb) bt
#0 0x00000000 in ?? ()
#1 0xa782eed4 in webrtc::PeerConnectionProxy::Send (this=0xab889e80, id=6, data=0xbfffc1e8)
at third_party/libjingle/source/talk/app/webrtc/peerconnectionproxy.cc:219
#2 0xa782e91a in ~PeerConnectionProxy (this=0xab889e80, __in_chrg=<value optimised out>)
at third_party/libjingle/source/talk/app/webrtc/peerconnectionproxy.cc:145
...
Breaking just before that line, I check that, as expected, signaling_thread_ is non-null, as is this and data. I'm just quite confused as to what could be causing a segfault there or making the stack end up at 0x00000000. The code only segfaults on the code path through the destructor. The Send function is called from numerous other places with no problem.
Update 2011-12-08:
Stepping through with stepi and disassembly turned on, I get this:
0xa772eed2 219 signaling_thread_->Send(this, id, data);
0xa772eea4 <_ZN6webrtc19PeerConnectionProxy4SendEjPN9talk_base11MessageDataE+24>: 8b 45 08 mov 0x8(%ebp),%eax
0xa772eea7 <_ZN6webrtc19PeerConnectionProxy4SendEjPN9talk_base11MessageDataE+27>: 8b 40 0c mov 0xc(%eax),%eax
0xa772eeaa <_ZN6webrtc19PeerConnectionProxy4SendEjPN9talk_base11MessageDataE+30>: 8b 00 mov (%eax),%eax
0xa772eeac <_ZN6webrtc19PeerConnectionProxy4SendEjPN9talk_base11MessageDataE+32>: 83 c0 40 add $0x40,%eax
0xa772eeaf <_ZN6webrtc19PeerConnectionProxy4SendEjPN9talk_base11MessageDataE+35>: 8b 08 mov (%eax),%ecx
0xa772eeb1 <_ZN6webrtc19PeerConnectionProxy4SendEjPN9talk_base11MessageDataE+37>: 8b 45 08 mov 0x8(%ebp),%eax
0xa772eeb4 <_ZN6webrtc19PeerConnectionProxy4SendEjPN9talk_base11MessageDataE+40>: 8d 70 04 lea 0x4(%eax),%esi
0xa772eeb7 <_ZN6webrtc19PeerConnectionProxy4SendEjPN9talk_base11MessageDataE+43>: 8b 45 08 mov 0x8(%ebp),%eax
0xa772eeba <_ZN6webrtc19PeerConnectionProxy4SendEjPN9talk_base11MessageDataE+46>: 8b 40 0c mov 0xc(%eax),%eax
0xa772eebd <_ZN6webrtc19PeerConnectionProxy4SendEjPN9talk_base11MessageDataE+49>: 8b 55 10 mov 0x10(%ebp),%edx
0xa772eec0 <_ZN6webrtc19PeerConnectionProxy4SendEjPN9talk_base11MessageDataE+52>: 89 54 24 0c mov %edx,0xc(%esp)
0xa772eec4 <_ZN6webrtc19PeerConnectionProxy4SendEjPN9talk_base11MessageDataE+56>: 8b 55 0c mov 0xc(%ebp),%edx
0xa772eec7 <_ZN6webrtc19PeerConnectionProxy4SendEjPN9talk_base11MessageDataE+59>: 89 54 24 08 mov %edx,0x8(%esp)
0xa772eecb <_ZN6webrtc19PeerConnectionProxy4SendEjPN9talk_base11MessageDataE+63>: 89 74 24 04 mov %esi,0x4(%esp)
0xa772eecf <_ZN6webrtc19PeerConnectionProxy4SendEjPN9talk_base11MessageDataE+67>: 89 04 24 mov %eax,(%esp)
=> 0xa772eed2 <_ZN6webrtc19PeerConnectionProxy4SendEjPN9talk_base11MessageDataE+70>: ff d1 call *%ecx
ecx
is 0x0 so that's what's making it segfault but I still don't understand what's going on. The other code for the line doesn't look to touch ecx
, unless I'm just reading it wrong.