Crashes upon map change.

All other Source.Python topics and issues.
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Crashes upon map change.

Postby Predz » Mon Mar 23, 2015 9:20 pm

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!
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Mon Mar 23, 2015 9:33 pm

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
Image
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Mon Mar 23, 2015 9:33 pm

Can you post the shortest plugin that causes a crash?
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Mon Mar 23, 2015 9:34 pm

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.". :p
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Postby Predz » Mon Mar 23, 2015 9:35 pm

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.
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Mon Mar 23, 2015 9:56 pm

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?
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Postby Predz » Mon Mar 23, 2015 10:16 pm

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).
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Mon Mar 23, 2015 10:19 pm

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".
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Postby Predz » Mon Mar 23, 2015 10:23 pm

The problem is inside Hero Wars, however there is a lot to check, so not to sure where to start.

Hero Wars
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Postby Predz » Mon Mar 23, 2015 10:25 pm

So taking a look at Satoon's link. Line 495 in hw.py could be the issue?

Edit: Still crashes.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Mon Mar 23, 2015 10:28 pm

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.
Image
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Mon Mar 23, 2015 10:49 pm

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?
Image
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Postby Predz » Mon Mar 23, 2015 10:52 pm

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.
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Mon Mar 23, 2015 11:51 pm

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?
User avatar
Doldol
Senior Member
Posts: 200
Joined: Sat Jul 07, 2012 7:09 pm
Location: Belgium

Postby Doldol » Tue Mar 24, 2015 12:58 am

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.
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Tue Mar 24, 2015 3:54 am

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()
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Postby Predz » Tue Mar 24, 2015 9:25 am

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.
Attachments
LOG.zip
(3.41 KiB) Downloaded 363 times
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Tue Mar 24, 2015 4:35 pm

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#L211

So, 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.
Image
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Postby Predz » Thu Mar 26, 2015 10:44 pm

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))
User avatar
Mahi
Senior Member
Posts: 236
Joined: Wed Aug 29, 2012 8:39 pm
Location: Finland

Postby Mahi » Sun Mar 29, 2015 3:33 pm

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 :) !

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 39 guests