Page 1 of 2
Crashes upon map change.
Posted: Mon Mar 23, 2015 9:20 pm
by Predz
Hey, have been playing with SP for a while now and have come across quite a large problem when using my dedicated server. The server is running Linux and am using the latest March 8th release. Server is running currently CSGO and CSS servers, however this problem only occurs on CSGO. Basically anytime a plugin is loaded and a map change happens, the individual server just crashes. No error logs I can find, instead it just restarts from the default map. If there aren't any plugins loaded then there is no problem changing map. Any help would be appreciated!
Have been testing using Hero Wars and some custom scripts, will share if you require to see them
Thanks All!
Posted: Mon Mar 23, 2015 9:33 pm
by satoon101
Have you tried narrowing it down to which script is causing the crashing? We can't really help until you have at least done that. Remove just the HeroWars plugin and see if the crashing continues. If it still crashes, continue removing plugins until you have narrowed it down.
My first guess would be that you have a known crashing issue. That issue is if you are hooking an event and also fire a new event from within an event being called. If I find the thread where this is discussed, I will edit it into this post.
*Edit: found it
http://forums.sourcepython.com/showthread.php?582
Posted: Mon Mar 23, 2015 9:33 pm
by Ayuto
Can you post the shortest plugin that causes a crash?
Posted: Mon Mar 23, 2015 9:34 pm
by L'In20Cible
Yes, the codes you are running would help to figure out what is going wrong. Currently, that's like going to the garage and tell them "Hey, my car is making some strange noises, I will bring it here if you need to check it out.".

Posted: Mon Mar 23, 2015 9:35 pm
by Predz
Np, this is the shortest script that still causes the problem. Even with only this loaded I still get crashes ;s
Syntax: Select all
##
##
##
from commands import CommandReturn
from commands.say import SayFilter
from messages import SayText2
from paths import PLUGIN_PATH
from translations.strings import LangStrings
##
##
##
strings = LangStrings('tags/tags')
@SayFilter
def say_filter(playerinfo, teamonly, command):
steamid = playerinfo.get_networkid_string()
if command.get_arg_string() == '""':
return CommandReturn.CONTINUE
if not '{0} {1}'.format(steamid, 'Text') in strings:
text = strings['Default Text'].get_string('en', text=command.get_arg_string().replace('"', ''))
name = strings['Default Name'].get_string('en', name=playerinfo.get_name())
message = '{name} : {text}'.format(name=name, text=text)
SayText2(message=message).send()
return CommandReturn.BLOCK
text = strings['{0} {1}'.format(steamid, 'Text')].get_string('en', text=command.get_arg_string().replace('"', ''))
name = strings['{0} {1}'.format(steamid, 'Name')].get_string('en', name=playerinfo.get_name())
message = '{name} : {text}'.format(name=name, text=text)
SayText2(message=message).send()
return CommandReturn.BLOCK
Edit: Also I just tried changing the map using "changelevel" in console however it doesn't seem to cause a crash, only when a map ends due to time/rounds/etc.
Posted: Mon Mar 23, 2015 9:56 pm
by Ayuto
Just tested both cases (changelevel and automatic map end) and I wasn't able to reproduce the crash on my Linux server. Do you have any other server plugins installed?
Posted: Mon Mar 23, 2015 10:16 pm
by Predz
KK Sorry, HW was loaded when I was testing and the problem lies in HW, just me not paying attention to my logs ;s
I have found this but I have no clue what it means.
Syntax: Select all
[SP] Loading plugin 'hw'...
[SP] Successfully loaded plugin 'hw'.
---- Host_Changelevel ----
*** Map Load: de_dust: Map Group mg_bombKeyValues Error: LoadFromBuffer: missing { in file gamemodes_server.txt
KeyValues Error: LoadFromBuffer: missing { in file gamemodes_server.txt
KeyValues Error: LoadFromBuffer: missing { in file gamemodes_server.txt
KeyValues Error: LoadFromBuffer: missing { in file gamemodes_server.txt
GameTypes: missing mapgroupsSP entry for game type/mode (custom/custom).
Posted: Mon Mar 23, 2015 10:19 pm
by L'In20Cible
missing { in file gamemodes_server.txt
It means exactly what it means. Check your gamemodes_server.txt file, there is a missing bracket. However, if you see that message, that means the crash is not related to that. The server is noticing you of the error. Post the code of "hw".
Posted: Mon Mar 23, 2015 10:23 pm
by Predz
The problem is inside Hero Wars, however there is a lot to check, so not to sure where to start.
Hero Wars
Posted: Mon Mar 23, 2015 10:25 pm
by Predz
So taking a look at Satoon's link. Line 495 in
hw.py could be the issue?
Edit: Still crashes.
Posted: Mon Mar 23, 2015 10:28 pm
by satoon101
I have been looking through the HeroWars code, and I don't see any event hooking already in-place. However, yes, if you have other plugins that have event hooking, calling another event from within an event (like line 495) will cause crashing.
Though, looking at that thread I posted again, it is stated to only happen on Windows. I have not personally tested that crash with Linux, but maybe it does occur there, too. I will test and report back. I do for a fact know that it will on Windows.
Posted: Mon Mar 23, 2015 10:49 pm
by satoon101
By "still crashes", what exactly have you tried? Does that mean you have tried not loading Hero Wars, and then subsequently removing other scripts until you narrow down which one(s) are causing the crashing? Have you removed 'all' SP plugins and are still crashing? What other plugins (MetaMod, SourceMod, SM plugins, etc..) are on your server, and have you tried removing them as well?
Posted: Mon Mar 23, 2015 10:52 pm
by Predz
I have removed everything apart from default SP and default Hero Wars, with them both loaded. And the crash still persists. Happens any time a map changes, however I have tried running Hero Wars by loading CSGO with the "insecure" command, and it changes map fine. So I am really confused.
Posted: Mon Mar 23, 2015 11:51 pm
by L'In20Cible
Can you upload your crash dump? Also, can you add -condebug to your command line and upload the content of console.txt after the crash?
Posted: Tue Mar 24, 2015 12:58 am
by Doldol
If this can be of any help:
On at least CSS, if during a map change you try to interact with the game and use an index, you'll crash. (I believe I was converting from a userid to an index.)
This seems logical to me, but could be causing this issue? I'm not sure, but I thought I'd mention it.
Posted: Tue Mar 24, 2015 3:54 am
by L'In20Cible
I think I found a possible cause of the crashes you are encountering. The problem here is that _Player instances are stored by their userid in a global list (player_list). While their userid won't change on new maps, their _playerinfo, _pointer and _edict instances are reallocated (normal, new "player" entities are created) and since those are cached in the Player/BaseEntity classes, you are randomly crashing at map changes cause those addresses are freed and accessing them later on is resulting in unexpected behaviors. This is a design issue on our ends to cache those, though. However, add the following to your players.py:
Syntax: Select all
from listeners import LevelInit
@LevelInit
def level_init(map_name):
global player_list
player_list = list()
Posted: Tue Mar 24, 2015 9:25 am
by Predz
Thanks for the help everyone however this hasn't seemed to of fixed the problem. I have had a look through the code and can't see any issues like you describe Doldol.
L'In, I have had -condebug on all the time, so the console.log below. Sorry there a couple of python errors because I was seeing if the materials were giving problems.
Sorry, had to be zipped as was to large to upload on website.
Posted: Tue Mar 24, 2015 4:35 pm
by satoon101
I am debugging it right now. It definitely crashes when it gets to this line:
https://github.com/Hero-Wars-Dev-Team/Hero-Wars/blob/master/addons/source-python/plugins/hw/hw.py#L211So, somewhere in the get_player function is where it crashes. I would imagine L'In20Cible is correct, that it is caused by accessing either the player's IPlayerInfo or edict_t instance.
Also, since we are using Python3, I would change that LevelInit to simply be:
Syntax: Select all
from listeners import LevelInit
@LevelInit
def level_init(map_name):
player_list.clear()
However, instead of the current implementation that uses a list, I would much rather use a dictionary class to store player's by their userid. Then, on LevelShutdown, I would clear the dictionary:
Syntax: Select all
class PlayerDictionary(dict):
def __missing__(self, userid):
value = self[userid] = PlayerEntitySubClass(index_from_userid(userid))
return value
def __delitem__(self, userid):
if userid in self:
super(PlayerDictionary, self).__delitem__(userid)
player_dictionary = PlayerDictionary()
@LevelShutdown
def level_shutdown():
player_dictionary.clear()
I get that caching the IPlayerInfo, edict_t, and pointer objects can cause crashing when access is attempted when the player (or entity) is no longer on the server. However, not caching them would cause us to have to get each of those instances constantly. I think with proper techniques, you can very easily avoid crashing with the current caching system.
Posted: Thu Mar 26, 2015 10:44 pm
by Predz
I have absolutely no clue how to fix this so I have just made a small fix for the meantime. I know it isn't very efficient, and probably a bad idea, so don't judge please. I just need some sort of minor fix so I can test server with people on :D
Syntax: Select all
##
##
##
from os.path import dirname
from engines.server import engine_server
from listeners import LevelShutdown, LevelInit
##
##
##
with open(dirname(__file__) + '/plugins.txt') as f:
lines = f.readlines()
plugins = list(lines)
##
##
##
@LevelInit
def level_init(map_name):
for plugin in plugins:
engine_server.server_command('sp load {0}'.format(plugin))
@LevelShutdown
def level_shutdown():
for plugin in plugins:
engine_server.server_command('sp unload {0}'.format(plugin))
Posted: Sun Mar 29, 2015 3:33 pm
by Mahi
My PC is currently broken, so there will be no updates for HW (from me) for a week or so. Thank you SP devs for working it out

!