Raised This Month: $ Target: $400
 0% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 06-21-2014 , 11:53   Functions what work fine in windows but crash in linux (research thread)
Reply With Quote #1

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!

Last edited by .Dare Devil.; 06-22-2014 at 23:37.
.Dare Devil. is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-21-2014 , 14:32   Re: Functions what work fine in windows but crash in linux
Reply With Quote #2

Always checking an entity is valid before doing something.
__________________
Arkshine is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 06-22-2014 , 12:36   Re: Functions what work fine in windows but crash in linux
Reply With Quote #3

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... )
.Dare Devil. is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-22-2014 , 13:27   Re: Functions what work fine in windows but crash in linux
Reply With Quote #4

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.
__________________

Last edited by Arkshine; 06-22-2014 at 13:48.
Arkshine is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 06-22-2014 , 14:34   Re: Functions what work fine in windows but crash in linux
Reply With Quote #5

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.
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 06-22-2014 , 14:42   Re: Functions what work fine in windows but crash in linux
Reply With Quote #6

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.

Last edited by .Dare Devil.; 06-22-2014 at 23:37.
.Dare Devil. is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 06-23-2014 , 01:25   Re: Functions what work fine in windows but crash in linux (research thread)
Reply With Quote #7

.Dare Devil., do you prеcache models/rpgrocket.mdl for set_view ?
__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 06-23-2014 , 01:46   Re: Functions what work fine in windows but crash in linux (research thread)
Reply With Quote #8

Quote:
Originally Posted by Bos93 View Post
.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.
.Dare Devil. 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 21:17.


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