Raised This Month: $51 Target: $400
 12% 

[CS:GO] Server crash when trying to "Kill" chicken


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
h3bus
AlliedModders Donor
Join Date: Nov 2013
Old 12-20-2013 , 03:53   [CS:GO] Server crash when trying to "Kill" chicken
Reply With Quote #1

Hello all,

I've got a nice segfault crash I can't pinpoint the root cause.
I'm trying to remove CS:GO chickens in my under-development deathmatch plugin. But for some reason the chicken removal code will randomly crash the server.

It works most of the time, but once in a while the removed chicken gives the server a headache!!

Here is the code that causes the crash
PHP Code:
public Action:Timer_OnChickenCreated(Handle:timerany:entity)
{
     if (
IsValidEdict(entity))
         
AcceptEntityInput(entity"Kill");
}

public 
OnEntityCreated(entity, const String:classname[])
{
     if (
g_bConfig_Enabled && (entity GetMaxClients()) && IsValidEdict(entity) && StrEqual(classname"chicken"))
         
CreateTimer(0.1Timer_OnChickenCreatedentityTIMER_FLAG_NO_MAPCHANGE);

Note: I added a timer because I guessed some attribute of the chicken entity/edict was not ready when OnEntityCreated is called but the following code gives the same crash:

PHP Code:
public OnEntityCreated(entity, const String:classname[])
{
    if (
g_bConfig_Enabled && (entity GetMaxClients()) && IsValidEdict(entity) && StrEqual(classname"chicken"))
        
AcceptEntityInput(entity"Kill")

I've also tried to filter invalid entity with both IsValidEntity && IsValidEdict, with the same result.

For information the crash stack is the following, with a segmentation fault:
Code:
0x0
server.so!CCSGameRules::Think() + 0xd5d
server.so!CGameRules::FrameUpdatePostEntityThink() + 0x49
server.so!IGameSystem::FrameUpdatePostEntityThinkAllSystems() + 0x84
server.so!CServerGameDLL::GameFrame(bool) + 0x217
sourcemod.2.csgo.so!__SourceHook_FHCls_IServerGameDLLGameFramefalse::Func(bool) [sourcemod.cpp:54 + 0x149]
engine.so!CServerPlugin::GameFrame(bool) + 0x82
engine.so!SV_Think(bool) + 0xbd
engine.so!SV_Frame(bool) + 0x110
engine.so!_Host_RunFrame_Server(bool) + 0xc5
engine.so!_Host_RunFrame(float) + 0x3eb
engine.so!Host_RunFrame(float) + 0x17b
engine.so!CHostState::State_Run(float) + 0x60
engine.so!.L190 + 0x12
engine.so!HostState_Frame(float) + 0x27
engine.so!CEngine::Frame() + 0x1a9
engine.so!CDedicatedServerAPI::RunFrame() + 0x35
dedicated.so!RunServer(bool) + 0x5e
dedicated.so!CDedicatedExports::RunServer() + 0x73
engine.so!CModAppSystemGroup::Main() + 0xb7
engine.so!CAppSystemGroup::Run() + 0x50
engine.so!CDedicatedServerAPI::ModInit(ModInfo_t&) + 0x22c
dedicated.so!CDedicatedAppSystemGroup::Main() + 0xca
dedicated.so!CAppSystemGroup::Run() + 0x50
dedicated.so!CSteamApplication::Main() + 0x4a
dedicated.so!CAppSystemGroup::Run() + 0x50
dedicated.so!main + 0x25d
dedicated.so!DedicatedMain + 0x24
srcds_linux + 0x90c
libc-2.15.so + 0x194d3
libc-2.15.so + 0x1a5ff4
ld-2.15.so + 0x146b0
libc-2.15.so + 0x193e9
ld-2.15.so + 0x20ff4
ld-2.15.so + 0xf280
ld-2.15.so + 0x21918
If you guys have any idea on what could be going on, or know a plugin that successfully stop chicken spawn/creation, dont mind to share ;)
h3bus is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 12-20-2013 , 04:38   Re: [CS:GO] Server crash when trying to "Kill" chicken
Reply With Quote #2

Why you dont use striper to remove it?
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.
GsiX is offline
h3bus
AlliedModders Donor
Join Date: Nov 2013
Old 12-20-2013 , 15:05   Re: [CS:GO] Server crash when trying to "Kill" chicken
Reply With Quote #3

Hadn't heard of it until now!

It seems like an overkill though :/
If nobody can help me find out what the catch here, i'll give it a try!
h3bus is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-20-2013 , 16:05   Re: [CS:GO] Server crash when trying to "Kill" chicken
Reply With Quote #4

A few things about the code...

1. Use the MaxClients value instead of the GetMaxClients() function. Although in CS:GO, it may be better to use the MAXPLAYERS constant since MaxClients can apparently change (this isn't clear in the CS:GO Quirks documentation).
2. Entities can in theory change between the time you start the timer and the time it executes. Unlike earlier games, CS:GO is much more aggressive about reusing entity indexes.

There is a way to address #2: Pass entity references to the timer.

PHP Code:
public Action:Timer_OnChickenCreated(Handle:timerany:entity)
{
     new 
realEntity EntRefToEntIndex(entity);
     if (
realEntity && IsValidEntity(realEntity))
         
AcceptEntityInput(realEntity"Kill");
}

public 
OnEntityCreated(entity, const String:classname[])
{
     if (
g_bConfig_Enabled && (entity GetMaxClients()) && IsValidEdict(entity) && StrEqual(classname"chicken"))
         
CreateTimer(0.1Timer_OnChickenCreatedEntIndexToEntRef(entity), TIMER_FLAG_NO_MAPCHANGE);

__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 12-20-2013 at 16:06.
Powerlord is offline
h3bus
AlliedModders Donor
Join Date: Nov 2013
Old 12-20-2013 , 19:52   Re: [CS:GO] Server crash when trying to "Kill" chicken
Reply With Quote #5

Thank you, your solution is running flawlessly on my two servers since one hour.

This means also that I need to rework all the entity indexes I send to Timers/callback, including clients. Using only userid/reference would ensure integrity of the processed data.
This is not so much work, but I wonder why most CS:GO plugins still use indexes when passing arguments to a delayed function.
h3bus is offline
xf117
Senior Member
Join Date: Mar 2010
Location: Russia
Old 12-21-2013 , 01:05   Re: [CS:GO] Server crash when trying to "Kill" chicken
Reply With Quote #6

Well, i would think if Ent index is the issue, you would not have it in your initial timer-less implementation.

Ent ref is not cs:go related problem. Ent index is just not reliable. And if you need to store it for some time, always use Ent ref. It's been on a wiki for a several years now i think.

AcceptEntityInput
does support ent ref by the way.
xf117 is offline
Send a message via ICQ to xf117
h3bus
AlliedModders Donor
Join Date: Nov 2013
Old 12-22-2013 , 08:20   Re: [CS:GO] Server crash when trying to "Kill" chicken
Reply With Quote #7

I guess the timer less implementation crashes because for some reason the entity is not complete yet when OnEntityCreated is called. This behavior seems really weird though.

Your remark on documentation is right, however informations are dispatched all over the place, it's quite hard for a beginner.
h3bus is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-23-2013 , 10:48   Re: [CS:GO] Server crash when trying to "Kill" chicken
Reply With Quote #8

Between map changes,
game "flush" entities (Creates and delete thems).
So helps to look OnEntityCreated after OnMapStart()

*edit
and yes, need little delay when entity created.

Last edited by Bacardi; 12-23-2013 at 10:50.
Bacardi is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 12-23-2013 , 15:34   Re: [CS:GO] Server crash when trying to "Kill" chicken
Reply With Quote #9

Quote:
Originally Posted by Powerlord View Post
A few things about the code...

1. Use the MaxClients value instead of the GetMaxClients() function. Although in CS:GO, it may be better to use the MAXPLAYERS constant since MaxClients can apparently change (this isn't clear in the CS:GO Quirks documentation).
2. Entities can in theory change between the time you start the timer and the time it executes. Unlike earlier games, CS:GO is much more aggressive about reusing entity indexes.

There is a way to address #2: Pass entity references to the timer.

PHP Code:
public Action:Timer_OnChickenCreated(Handle:timerany:entity)
{
     new 
realEntity EntRefToEntIndex(entity);
     if (
realEntity && IsValidEntity(realEntity))
         
AcceptEntityInput(realEntity"Kill");
}

public 
OnEntityCreated(entity, const String:classname[])
{
     if (
g_bConfig_Enabled && (entity GetMaxClients()) && IsValidEdict(entity) && StrEqual(classname"chicken"))
         
CreateTimer(0.1Timer_OnChickenCreatedEntIndexToEntRef(entity), TIMER_FLAG_NO_MAPCHANGE);


Why so much effort?
Why not simply hook the sdk's spawn output? That's what it is for.
__________________
Santa or Satan?

Watch out when you're paying people for private requests! Most stuff already exists and you can hardly assess the quality of what you'll get, and if it's worth the money.
Dr. Greg House is offline
usla
Senior Member
Join Date: Jul 2009
Old 10-26-2016 , 20:11   Re: [CS:GO] Server crash when trying to "Kill" chicken
Reply With Quote #10

anyone found a way to stop chickens from respawning ? i had no luck with stripper
usla is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:59.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode