AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Functions what work fine in windows but crash in linux (research thread) (https://forums.alliedmods.net/showthread.php?t=242575)

.Dare Devil. 06-21-2014 11:53

Functions what work fine in windows but crash in linux (research thread)
 
Hello alliedmodders!
I thought i should post it somewhere else but all we do here is talk about scripting and functions so i hope i did the right thing.

I made a huge plugin what is working fine in windows but crash in linux.
So far i found out that using Ham_think
PHP Code:

public fw_think(entid)
{
    if( 
g_needtoremove remove_entity(ent)


This will crash linux but not windows

Correct code:
PHP Code:

public fw_think(entid)
{
    if( 
g_needtoremove 
    {
         
remove_entity(ent)
         return 
HAM_SUPERCEDE
    
}
    return 
HAM_IGNORED


I also know that sending messages with wrong player id causes crash in linux.
Well, now i fixed everything in my code what i know.
There is still something i dont know and something still causes the crash.

My question here is that what else causes crash on linux but not in windows.
There cant be that many things.
Thanks!

Arkshine 06-21-2014 14:32

Re: Functions what work fine in windows but crash in linux
 
Always checking an entity is valid before doing something.

.Dare Devil. 06-22-2014 12:36

Re: Functions what work fine in windows but crash in linux
 
I tested somethings
PHP Code:

public test_thing(id)
{
    
client_print(1print_chat"test 8"  )
    static 
ent
    ent 
create_entity("info_target")
    
remove_entity(ent)
        
// added x function here 

list of function tested ( x functions )
PHP Code:

remove_entity(ent)
dllfunc(DLLFunc_Spawnent)
set_pev(entpev_solidSOLID_NOT)
entity_set_size(entFloat:{ -3.0, -3.0, -3.0 }, Float:{ 3.03.03.0 } )
set_peventpev_aimentid // i guess set_pev is safe and dont matter what im sending here
engfunc(EngFunc_RemoveEntityent)
entity_set_model(entprecachedvalid_model

I tested them one by one and non of them crashed my server.
Just got error logs (invalid entity)

Now the problem is that when im doing something with entities im using always set_pev
( im replacing them soon with engine but since it is easier to write with pev im using that )

And the funny thing is that i never got error logs saying entity is invalid.
I also checked my code and i check everytime if user is connected or is entity valid.
Im out of ideas now.

I need to find those functions what crash ohter ways all that huge work creating that mod was useless because it cant be used if it is crashing.
There is still one thing what i havent tested and that is entity count.
If there are more than 1300 + something entities server crashes.
( seems pretty ridiculous that i reached that limit but who knows... )

Arkshine 06-22-2014 13:27

Re: Functions what work fine in windows but crash in linux
 
You need to stop overthinking, stop wasting your time with weird tests, and simply adding sanity check before doing something like pev_valid/is_valid_ent.

GuskiS 06-22-2014 14:34

Re: Functions what work fine in windows but crash in linux
 
PHP Code:

public Ham_Touch_pre(entother)
{
    if(!
is_valid_ent(ent))
        return 
HAM_IGNORED;

    if(
is_user_alive(other))
    {
        new 
owner entity_get_edict(entEV_ENT_owner);
        
//ExecuteHamB(Ham_Killed, other, owner, 0);
        
ExecuteHamB(Ham_TakeDamageotherentowner300.0, (<< 24));
    }


        
emit_sound(entCHAN_AUTO"player/pl_snow1.wav"1.0ATTN_NORM0PITCH_NORM);
        static 
Float:origin[3];
        
entity_get_vector(entEV_VEC_originorigin);
        
sw_effect(origin);
        
remove_entity(ent);


    return 
HAM_SUPERCEDE;


Here is my code which was crashing. Which I discovered was that entity got removed or something like that and server crashed on remove_entity. After putting it in is_valid_ent check it worked fine. Don't know why that happened, but might be ham deleting my entity? Because it was crashing only when I hit player.

.Dare Devil. 06-22-2014 14:42

Re: Functions what work fine in windows but crash in linux
 
Thanks Arkshine and GuskiS.
I found one new crash type yet i dont know how to explain it yet because i dont understand it.
It is something to do with set_view(id, CAMERA_3RDPERSON)
i should recode my player model system because it is doing strange things sometimes.
I tried to be friendly with old version and code got really complicated.

Edit:
If you set player model's submodel what is blank then use set_view(id, CAMERA_3RDPERSON)
server will crash.

If you find/know something then this thread is always welcome to accept your crash cause.

Bos93 06-23-2014 01:25

Re: Functions what work fine in windows but crash in linux (research thread)
 
.Dare Devil., do you prеcache models/rpgrocket.mdl for set_view ?

.Dare Devil. 06-23-2014 01:46

Re: Functions what work fine in windows but crash in linux (research thread)
 
Quote:

Originally Posted by Bos93 (Post 2155947)
.Dare Devil., do you prеcache models/rpgrocket.mdl for set_view ?

yes but now i dont use that crap anymore.
I made my own set_view function but since it having some troubles i need to create new topic.


All times are GMT -4. The time now is 21:17.

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