Page 1 of 1
SayText2 send() crashes server (LATEST BUILD)
Posted: Thu Jan 03, 2013 7:05 pm
by Tuck
So the builds from dec 21 (i estimate) crashes hole server when you .send the sayText2 obj
i would like a fix very quick, if possible

more accurate, crashes in
_send_message method, after GameEngine.MessageEnd()
Posted: Thu Jan 03, 2013 7:22 pm
by freddukes
I'm using it without issue in SourceRPG. How are you using it? This is my code and it works fine:
Syntax: Select all
from messages import SayText2
from events import Event
from players.helpers import index_from_userid
class Player(object):
def __init__(self, index):
self.index = index
def send_message(self, message, index=None):
"""Sends a message to the player
@param str message A message to send
"""
message = SayText2(message, index if index is not None else self.index,
self.index)
message.send()
#### Events
@Event
def player_spawn(GameEvent):
userid = GameEvent.GetInt("userid")
index = index_from_userid(userid)
Player(index).send_message("Hello there")
-freddukes
Posted: Thu Jan 03, 2013 7:42 pm
by Tuck
example code that crashes:
Syntax: Select all
from Source import Player
from messages import SayText2
from events import Event
@Event
def player_say(GameEvent):
userid = GameEvent.GetInt('userid')
if int(userid or 0) > 0:
index = Player.IndexOfUserid(userid)
obj = SayText2('Testing 123', index, index)
obj.send()
Posted: Thu Jan 03, 2013 7:53 pm
by freddukes
Hmm strange. I have got the latest source and compiled it though; which version have you got? Are you running the version uploaded to these forums?
-freddukes
Posted: Thu Jan 03, 2013 7:55 pm
by Tuck
freddukes wrote:Hmm strange. I have got the latest source and compiled it though; which version have you got? Are you running the version uploaded to these forums?
-freddukes
the latest source compiled as Release and not debug due to .dll issues, but that shouldnt be a problem?
Posted: Thu Jan 03, 2013 8:00 pm
by freddukes
Hmm I can't remember whether I'm running debug or release; I think I'm running debug. It could be an issue; usually debug does things like automatically initialise variables to 0 or some other value (sometimes a memory fill pattern like 0xCDCDCDCD) whereas release will usually just fill it with whatever exists at that address at that time. It can lead to random issues which won't replicate unless in release. Release also does things like function inlining, loop unrolling, code reordering etc which can also mess up flow and cause other issues which can be difficult to debug.
I'll run your code under a release build to see if I can replicate the crash.
-freddukes
Posted: Thu Jan 03, 2013 8:01 pm
by Tuck
freddukes wrote:Hmm I can't remember whether I'm running debug or release; I think I'm running debug. It could be an issue; usually debug does things like automatically initialise variables to 0 or some other value (sometimes a memory fill pattern like 0xCDCDCDCD) whereas release will usually just fill it with whatever exists at that address at that time. It can lead to random issues which won't replicate unless in release. Release also does things like function inlining, loop unrolling, code reordering etc which can also mess up flow and cause other issues which can be difficult to debug.
I'll run your code under a release build to see if I can replicate the crash.
-freddukes
i build the release my self, not a official release being used.
Heres some information:
i could run debug if there was a option to include MSVCR100D.dll into the build or to place it next to srcds or something like that, i have to install visual studio 2010 before this file is located at the computer..the #1 to #8 is basicly to debug which line crashes i've stated that in earlier post.Quick note for how i build the release:- Starting "source-python.sln" in Visual studio 2010 C++ Express
- Right click Solution -> Configuration Manager..
- Changin Active solution configuration, to "Release"
- Build solution
Posted: Thu Jan 03, 2013 8:22 pm
by freddukes
Okay, confirmed it crashes; it only crashes in a release build. I'm guessing it's using an uninitialised variable. I'll try and fix the C++ side; cheers.
-freddukes
Posted: Thu Jan 03, 2013 9:20 pm
by freddukes
Heh... L'In20Cible and I were working on a fix; seems like release does some weird code removal on the destructor of MRecipientFilter... It seems it won't properly call the dtor unless there's a definition of it in the CPP (will not work if placed in the header :S).
I will do some more testing and check in a fix later on.
-freddukes
Posted: Fri Jan 04, 2013 4:24 am
by Tuck
freddukes wrote:Heh... L'In20Cible and I were working on a fix; seems like release does some weird code removal on the destructor of MRecipientFilter... It seems it won't properly call the dtor unless there's a definition of it in the CPP (will not work if placed in the header :S).
I will do some more testing and check in a fix later on.
-freddukes
Okay thanks

, keep me updated :P
Posted: Fri Jan 04, 2013 10:47 pm
by freddukes
https://code.google.com/p/source-python/source/detail?r=ce753893a711fb0a3df3840dc06f62ae07f4b7e6Getting latest should fix your crash. It's not a complete fix, I've still got to figure out why ShowMenu doesn't work (but SayText2 should now work in release).
From what I could understand, compiler optimisations caused the inline ctor / dtor to invoke a copy constructor on the CUtlVector which copied the heap memory allocator's pointer. When the copy was destroyed, it deleted the heap allocation which meant when the actual memory allocator was destroyed at the right time it attempted to free the memory at that heap location twice, causing a heap error. I have no idea why the optimisations caused this.
Big thanks to L'In20Cible for finding the original problem and proposing the fix.
-freddukes
Posted: Sun Jul 07, 2013 7:05 pm
by Omega_K2
Seems like it crashes again, though not insantly. Few seconds after a message sent srcds crashes.
Posted: Sun Jul 07, 2013 7:19 pm
by Tuck
Omega_K2 wrote:Seems like it crashes again, though not insantly. Few seconds after a message sent srcds crashes.
I don't think you've been experiencing the same issue as i was, could you create a small script that crashes the server and put some debug messages in to figure what line/function/method crashes it, Also state if you compiled it as release or debug.
edit: if the crash happens a few seconds later figure out what method you called and maybe put some debug messages into the imported method usedThanks in advance
Posted: Sun Jul 07, 2013 8:34 pm
by Omega_K2
yeah actually ingore it, I think the server just bugged when I tried this earlier.
EDIT: It could crash with a 100% chance pretty much whenever I tried it, it was just matter of executing client command, then showing the message, then waiting 1-10 secs for the crash. But no idea what caused it, server is just running SP and nothing else pretty much