SayText2 send() crashes server (LATEST BUILD)

Please post any questions about developing your plugin here. Please use the search function before posting!
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

SayText2 send() crashes server (LATEST BUILD)

Postby Tuck » Thu Jan 03, 2013 7:05 pm

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()
-Tuck
freddukes
Developer
Posts: 29
Joined: Mon Nov 19, 2012 10:12 pm

Postby freddukes » Thu Jan 03, 2013 7:22 pm

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
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Thu Jan 03, 2013 7:42 pm

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()
-Tuck
freddukes
Developer
Posts: 29
Joined: Mon Nov 19, 2012 10:12 pm

Postby freddukes » Thu Jan 03, 2013 7:53 pm

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
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Thu Jan 03, 2013 7:55 pm

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?
-Tuck
freddukes
Developer
Posts: 29
Joined: Mon Nov 19, 2012 10:12 pm

Postby freddukes » Thu Jan 03, 2013 8:00 pm

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
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Thu Jan 03, 2013 8:01 pm

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:
  1. Starting "source-python.sln" in Visual studio 2010 C++ Express
  2. Right click Solution -> Configuration Manager..
  3. Changin Active solution configuration, to "Release"
  4. Build solution
Attachments

[The extension txt has been deactivated and can no longer be displayed.]

Untitled.jpg
-Tuck
freddukes
Developer
Posts: 29
Joined: Mon Nov 19, 2012 10:12 pm

Postby freddukes » Thu Jan 03, 2013 8:22 pm

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
freddukes
Developer
Posts: 29
Joined: Mon Nov 19, 2012 10:12 pm

Postby freddukes » Thu Jan 03, 2013 9:20 pm

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
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Fri Jan 04, 2013 4:24 am

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
-Tuck
freddukes
Developer
Posts: 29
Joined: Mon Nov 19, 2012 10:12 pm

Postby freddukes » Fri Jan 04, 2013 10:47 pm

https://code.google.com/p/source-python/source/detail?r=ce753893a711fb0a3df3840dc06f62ae07f4b7e6

Getting 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
Omega_K2
Senior Member
Posts: 227
Joined: Sat Jul 07, 2012 3:05 am
Location: Europe
Contact:

Postby Omega_K2 » Sun Jul 07, 2013 7:05 pm

Seems like it crashes again, though not insantly. Few seconds after a message sent srcds crashes.
Libraries: k2tools
Plugins (any): GSRPG (soon) | Pretty Status List | MySQLAds (soon)
Plugins (game-specific): None atm

If you happen to find a bug or need help, either post in the release threads or contact me in IRC gamesurge.net:6667 / #sourcepython
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Sun Jul 07, 2013 7:19 pm

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 used

Thanks in advance
-Tuck
Omega_K2
Senior Member
Posts: 227
Joined: Sat Jul 07, 2012 3:05 am
Location: Europe
Contact:

Postby Omega_K2 » Sun Jul 07, 2013 8:34 pm

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
Libraries: k2tools

Plugins (any): GSRPG (soon) | Pretty Status List | MySQLAds (soon)

Plugins (game-specific): None atm



If you happen to find a bug or need help, either post in the release threads or contact me in IRC gamesurge.net:6667 / #sourcepython

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 24 guests