AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   register_touch crashes server (https://forums.alliedmods.net/showthread.php?t=240553)

GuskiS 05-17-2014 18:40

register_touch crashes server
 
I have server running with some plugins, 2 of them have register_touch in them. Once a while I get crash. No idea why, in crash log it say something about sv_touchlinks.

Plugin 1:
PHP Code:

register_touch("weaponbox""player""Touch_WeaponBox");

public 
Touch_WeaponBox(entid)
{
    if(
get_game_mode() != GAME_STARTED)
        return 
PLUGIN_HANDLED;
    if(!(
entity_get_int(entEV_INT_flags) & FL_ONGROUND))
        return 
PLUGIN_CONTINUE;

    if(
is_user_alive(id))
    {
        if(
get_user_pd(idPD_CANTPICK))
            return 
PLUGIN_HANDLED;
        
        if(
get_user_class(id) == CLASS_BYSTANDER)
            
set_user_class(idCLASS_ARMED);
        else if(
get_user_class(id) == CLASS_MURDERER)
            return 
PLUGIN_HANDLED;

        
pickup_weapon(idCSW_DEAGLE);
        
cs_set_user_bpammo(idCSW_DEAGLE6);
    }

    return 
PLUGIN_CONTINUE;


What this code is supposed to do is block deagle pickup (only weapon in game) if the conditions are met, else allow to pick it, play hud sprite, give some ammo.

Plugin 2:
PHP Code:

register_touch("mm_knife_throw""*""Touch_Knife"); 

public 
Touch_Knife(knifeid)
{
    if(!
is_valid_ent(knife))
        return;

    if(
is_user_alive(id))
    {
        if(
entity_get_int(knifeEV_INT_movetype) == MOVETYPE_NONE)
        {
            if(
mm_get_playerdata(idPD_CLASS) == CLASS_MURDERER)
                
give_murder_knife(idknife);
        }
        else
        {
            new 
owner entity_get_edict(knifeEV_ENT_owner);
            if(
owner == id || !owner)
                return;

            
remove_entity(knife);
            
ExecuteHamB(Ham_Killedidowner0);
            
emit_sound(idCHAN_ITEM"weapons/knife_hit4.wav"1.0ATTN_NORM0PITCH_NORM);

            
create_knife(id101);
        }
    }
    else
    {
        
entity_set_int(knifeEV_INT_movetypeMOVETYPE_NONE);
        new 
dropped drop_to_floor(knife);
        if(!
dropped)
        {
            new 
numFloat:origin[3];
            
entity_get_vector(knifeEV_VEC_originorigin);
            
dropped make_vacant(knifeoriginnum15.0);
        }

        if(!
dropped)
            
give_murder_knife(entity_get_edict(knifeEV_ENT_owner), knife);
        else
        {
            
entity_set_size(knifeg_szDroppedSize[0], g_szDroppedSize[1]);
            
drop_to_floor(knife);
            
entity_set_edict(knifeEV_ENT_owner0);
            
            
emit_sound(knifeCHAN_ITEM"weapons/knife_hitwall1.wav"1.0ATTN_NORM0PITCH_NORM);
        }
        static 
Float:angles[3];
        
entity_get_vector(knifeEV_VEC_anglesangles);
        
angles[0] = 270.0;
        
entity_set_vector(knifeEV_VEC_anglesangles);
    }


This code is for throwing a knife. First check if target is alive, if yes, check movetype, if none can pickup, else remove entity, create new and kill target. If target is not alive it tries to drop to floor the knife, if can drop, nice, change size etc. Else, find a vacant place and then drop it(if stuck is sky box, too high from ground etc.)

So what I have noticed is that crash happens when knife (so plugin 2, but cant be sure) hits player, BUT rarely. So I don't know whats wrong. :(

aron9forever 05-18-2014 07:34

Re: register_touch crashes server
 
you need to start debugging by adding prints at every action
see if code#1 is called when a thrown knife hits a player, that would probably cause some issues because this right here "else if(get_user_class(id) == CLASS_MURDERER)
return PLUGIN_HANDLED;", if your first plugin is above the second one in plugins.ini, would completely block other plugins from using the touch

GuskiS 05-18-2014 07:44

Re: register_touch crashes server
 
As you can see, both register different classname. So they can't block each other, but.. The thing that could happen is, when knife hit player which carries deagle, then both touches could occur - dropping gun, hit by knife.
Also, codes are orderered as they are in plugins.ini.
Thanks for your reply. :)

aron9forever 05-18-2014 07:55

Re: register_touch crashes server
 
I still suggest adding server prints to everything, then check logs for crash, see what happens exactly, it's the easiest way to solve all problems

post exact crash error

meTaLiCroSS 05-18-2014 16:48

Re: register_touch crashes server
 
Touch called is not called 1 time, as I see on your first code, if an user walks over the entity the forward will be called every frame when moving on it, and overflowing and overflowing..

Start by debuging your code with messages, and see how it is working.

GuskiS 05-18-2014 17:57

Re: register_touch crashes server
 
Here is the crash log:
Code:

CRASH: Sun May 18 19:26:21 EEST 2014
[New LWP 24166]
[New LWP 24173]
[New LWP 24381]
[New LWP 24383]
[New LWP 9885]
[New LWP 24169]
[New LWP 24384]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program terminated with signal 11, Segmentation fault.
#0  SV_TouchLinks (ent=0xf3943ae4, node=0xf7444340) at ../engine/world.c:396
#0  SV_TouchLinks (ent=0xf3943ae4, node=0xf7444340) at ../engine/world.c:396
#1  0xf6fb0141 in SV_TouchLinks (ent=0xf3943ae4, node=0xf7444320) at ../engine/world.c:456
#2  0xf6fb0141 in SV_TouchLinks (ent=0xf3943ae4, node=0xf7444300) at ../engine/world.c:456
#3  0xf6fb0141 in SV_TouchLinks (ent=0xf3943ae4, node=0xf74442e0) at ../engine/world.c:456
#4  0xf6fb0141 in SV_TouchLinks (ent=0xf3943ae4, node=0xf74442c0) at ../engine/world.c:456
#5  0xf6fb02e8 in SV_LinkEdict (ent=0xf3943ae4, touch_triggers=true) at ../engine/world.c:602
#6  0xf6fab9f6 in SV_RunCmd (ucmd=0xffa22900, random_seed=53558) at ../engine/sv_user.c:1149
#7  0xf6fabf00 in SV_ParseMove (pSenderClient=<optimized out>) at ../engine/sv_user.c:1998
#8  0xf6fac335 in SV_ExecuteClientMessage (cl=0xf3871f08) at ../engine/sv_user.c:2221
#9  0xf6f9e663 in SV_ReadPackets () at ../engine/sv_main.c:4871
#10 0xf6f9e8de in SV_Frame () at ../engine/sv_main.c:9216
#11 0xf6f66e52 in _Host_Frame (time=0.00108729606) at ../engine/host.c:1404
#12 0xf6f67212 in Host_Frame (time=0.00108729606, iState=1, stateInfo=0xffa2382c) at ../engine/host.c:1522
#13 0xf6f8b86c in CEngine::Frame (this=0xf70226a0) at ../engine/sys_engine.cpp:245
#14 0xf6f88bd3 in RunFrame (this=<optimized out>) at ../engine/sys_dll2.cpp:1235
#15 CDedicatedServerAPI::RunFrame (this=0xf701dd00) at ../engine/sys_dll2.cpp:1226
#16 0x08049c65 in RunServer () at ../dedicated/sys_ded.cpp:770
#17 0x08049472 in main (argc=20, argv=0xffa23a64) at ../dedicated/sys_ded.cpp:1150
contents = <optimized out>
hull = <optimized out>
offset = {-3.9806878e+33, -1.61293372e+31, -64.545372}
localPosition = {125.247734, 0, -1.61287484e+31}
l = 0x0
next = <optimized out>
touch = <optimized out>
pModel = <optimized out>
From        To          Syms Read  Shared Object Library
0xf76c9914  0xf770fc78  Yes        ./libstdc++.so.6
0xf766fa60  0xf7670a08  Yes (*)    /lib/i386-linux-gnu/libdl.so.2
0xf7657650  0xf7663a78  Yes (*)    /lib/i386-linux-gnu/libpthread.so.0
0xf74bff10  0xf75f544c  Yes (*)    /lib/i386-linux-gnu/libc.so.6
0xf7481430  0xf749baf8  Yes (*)    /lib/i386-linux-gnu/libm.so.6
0xf7759820  0xf7771baf  Yes (*)    /lib/ld-linux.so.2
0xf7469e04  0xf7479490  Yes        ./libgcc_s.so.1
0xf6f4d450  0xf6fd118c  Yes        /var/servers/ttt/engine_i486.so
0xf6ef35c0  0xf6efdd74  Yes (*)    ./libsteam_api.so
0xf6ee98d0  0xf6eed618  Yes (*)    /lib/i386-linux-gnu/librt.so.1
0xf6ed0a00  0xf6edd1b8  Yes        /var/servers/ttt/filesystem_stdio.so
0xf6083900  0xf6ade82c  Yes (*)    ./steamclient.so
0xf5ebd670  0xf5f33020  Yes (*)    ./crashhandler.so
0xf3640b70  0xf3656984  Yes        /var/servers/ttt/./cstrike/addons/metamod/dlls/metamod.so
0xf3403370  0xf35273b0  Yes        /var/servers/ttt/cstrike/dlls/cs.so
0xf32ccbf0  0xf3318bb8  Yes (*)    /var/servers/ttt/cstrike/addons/amxmodx/dlls/amxmodx_mm_i386.so
0xf7679db0  0xf767cd9c  Yes (*)    cstrike/addons/amxmodx/modules/fun_amxx_i386.so
0xf32ac330  0xf32b2584  Yes (*)    cstrike/addons/amxmodx/modules/cstrike_amxx_i386.so
0xf3235c70  0xf323bb3c  Yes (*)    cstrike/addons/amxmodx/modules/csx_amxx_i386.so
0xf7675920  0xf7676378  Yes (*)    /var/servers/ttt/cstrike/addons/bsploaderfixer/bsploaderfixer_i386.so
0xf2cbf0d0  0xf2d4e030  Yes (*)    cstrike/addons/amxmodx/modules/mysql_amxx_i386.so
0xf2c5b760  0xf2c68668  Yes (*)    /lib/i386-linux-gnu/libz.so.1
0xf2c49080  0xf2c53e4c  Yes (*)    cstrike/addons/amxmodx/modules/engine_amxx_i386.so
0xf2bfe630  0xf2c2a144  Yes (*)    cstrike/addons/amxmodx/modules/fakemeta_amxx_i386.so
0xf2ba0d70  0xf2bd1d6c  Yes (*)    cstrike/addons/amxmodx/modules/hamsandwich_amxx_i386.so
0xf2abc620  0xf2b34bd8  Yes (*)    cstrike/addons/amxmodx/modules/orpheu_amxx_i386.so
0xf2c38a10  0xf2c3fb18  Yes (*)    /lib/i386-linux-gnu/libnss_files.so.2
0xf12b8470  0xf153de08  Yes (*)    /var/servers/ttt/libsteam.so
0xf2e6bba0  0xf2e6eb68  Yes (*)    /lib/i386-linux-gnu/libnss_dns.so.2
0xf11606b0  0xf116d578  Yes (*)    /lib/i386-linux-gnu/libresolv.so.2
(*): Shared library is missing debugging information.
Stack level 0, frame at 0xffa22600:
 eip = 0xf6faffa3 in SV_TouchLinks (../engine/world.c:396); saved eip 0xf6fb0141
 called by frame at 0xffa22660
 source language c.
 Arglist at 0xffa225ac, args: ent=0xf3943ae4, node=0xf7444340
 Locals at 0xffa225ac, Previous frame's sp is 0xffa22600
 Saved registers:
  ebx at 0xffa225ec, ebp at 0xffa225f8, esi at 0xffa225f0, edi at 0xffa225f4, eip at 0xffa225fc
End of crash report
----------------------------------------------

meTaLiCroSS, what do you mean by overflowing? In first code I just block weapon pickup with PLUGIN_HANDLED.

NiHiLaNTh 05-19-2014 09:40

Re: register_touch crashes server
 
He means that when touch something, touch will be called a lot of times. The problem might be inside pickup_weapon function.

GuskiS 05-19-2014 10:50

Re: register_touch crashes server
 
pickup_weapon is just stock for hud sprite, WeapPickup message.

Backstabnoob 05-19-2014 11:12

Re: register_touch crashes server
 
I don't know what the functions in your first callback do, but you're not removing the weapon or checking if the user already has it, so the WeapPickup message will be sent 60 times per second to the player.

aron9forever 05-19-2014 11:41

Re: register_touch crashes server
 
Quote:

Originally Posted by Backstabnoob (Post 2139936)
I don't know what the functions in your first callback do, but you're not removing the weapon or checking if the user already has it, so the WeapPickup message will be sent 60 times per second to the player.

that crashes the client not the server
or it would spout out a netchan error, not something like this

add a print after each and every line in order, eg server_print 1, 2 , 3 etc and when it crashes you will se exactly which was the last line that was run, probably the bogus one


All times are GMT -4. The time now is 09:44.

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