OK, I didn't really want to do this, but...
Is it possible to attach a watch on a class/object's property?
I'm writing a SourceMod Extension for vote handling using TF2 votes, based quite heavily on the SourceMod vote system. The problem I'm having is that one of my global classes is throwing a SIGSEGV after I copy one of its pointer properties to a new pointer and try to call a method on it.
Specifically, this happens if no one votes (I haven't tested the voting yet to make sure votes are tallying correctly).
Note: The attached code needs a lot of cleanup yet, with the wholesale slashing of some unnecessary blocks (like anything dealing with the watch list).
The relevant parts of the code are (in the order they're called):
extension.cpp line 50, where s_VoteHandler is created just once (so it's a global).
nativse.cpp line 299, where a pointer to a new CBuiltinVoteHandler is created, or an old, no longer used pointer is retrieved from the pool during vote creation. During testing, this was the first vote created. This is during the CreateBuiltinVote native.
natives.cpp line 314, where the vote is started from the DisplayBuiltinVote native.
BuiltinVoteHandler.cpp line 378, where the CBuiltinVoteHandler pointer from earlier is copied to BulltinVoteHandler's m_pHandler pointer.
BuiltinVoteHandler.cpp line 380, where we send a command to the handler. We know m_pHandler is valid at this point.
BuiltinVoteHandler.cpp line 396, where the timer starts.
BuiltinVoteHandler.cpp line 723, where the timer stops.
BuiltinVoteHandler.cpp line 733, where EndVoting is called after the timer stops
BuiltinVoteHandler.cpp line 484, where the m_pHandler pointer is copied to a local variable
BuiltinVoteHandler.cpp line 614, where m_pHandler is set to NULL.
BuiltinVoteHandler.cpp line 486, where the SIGSEGV for the local handler happens during the EndVoting method.
Note: I haven't yet tested this on Windows. Also, you need to compile it for Orange Box Valve. The msvc9 and msvc10 projects should both work, as should the Makefile.
Edit: I forgot to mention, no natives are called after DisplayBuiltinVote before the crash.
Edit 2: If it's not that easy, I suppose I could set up a local dedicated server to test it using Visual Studio.
__________________
Not currently working on SourceMod plugin development.
Last edited by Powerlord; 10-11-2011 at 14:33.
|