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

amxx 1.8.3 code crash


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JusTGo
Veteran Member
Join Date: Mar 2013
Old 04-02-2016 , 14:39   amxx 1.8.3 code crash
Reply With Quote #1

i get FATAL ERROR (shutting down): Bad entity in IndexOfEdict(). when using a code this code
PHP Code:
#include < amxmodx >
#include < engine >
#include < fakemeta >
#include < hamsandwich >
#include < xs >

public plugin_init( ) {
    
register_clcmd"say /test""CmdTest" );
}

public 
CmdTest(id)
{
    
register_forward(FM_TraceLine"fw_traceline")
}

public 
fw_traceline(Float:start[3], Float:end[3], conditionsidtrace)
{
    static 
pHit;
    
pHit get_tr2traceTR_pHit );

problem doesn't exist in amxx 1.8.2
__________________

Last edited by JusTGo; 04-02-2016 at 16:09.
JusTGo is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-02-2016 , 15:39   Re: amxx 1.8.3 entity crash
Reply With Quote #2

Write a small test plugin that recreates the issue and post that. That is the best way to help fix the issue. Also, make sure that you are using the latest version of the dev version.
__________________

Last edited by fysiks; 04-02-2016 at 15:40.
fysiks is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 04-02-2016 , 16:06   Re: amxx 1.8.3 entity crash
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
Write a small test plugin that recreates the issue and post that. That is the best way to help fix the issue. Also, make sure that you are using the latest version of the dev version.
after alot of time debuging the code i found that the problem in amxx 1.8.3 only and not on 1.8.2 here is the code to reproduce the error with the lastest amxx dev.
PHP Code:
#include < amxmodx >
#include < engine >
#include < fakemeta >
#include < hamsandwich >
#include < xs >

public plugin_init( ) {
    
register_clcmd"say /test""CmdTest" );
}

public 
CmdTest(id)
{
    
register_forward(FM_TraceLine"fw_traceline")
}

public 
fw_traceline(Float:start[3], Float:end[3], conditionsidtrace)
{
    static 
pHit;
    
pHit get_tr2traceTR_pHit );

__________________
JusTGo is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-02-2016 , 16:16   Re: amxx 1.8.3 code crash
Reply With Quote #4

You're saying that calling get_tr2 with TR_pHit in this forward crashes always the server with the error you mentioned?
__________________
Arkshine is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 04-02-2016 , 16:18   Re: amxx 1.8.3 code crash
Reply With Quote #5

Quote:
Originally Posted by Arkshine View Post
You're saying that calling get_tr2 with TR_pHit in this forward crashes always the server with the error you mentioned?
i m not sure what is the name of the error cause im on windows now and i m using last amxx 1.8.3 dev and it crashs when i say /test.

edit1:

here is some logs

PHP Code:
L 04/02/2016 21:38:15Log file started (file "cstrike\addons\amxmodx\logs\hlds_crash.log") (game "cstrike") (amx "1.8.3-dev+5044")
L 04/02/2016 21:38:15Sys_Error: [Bad entity in IndexOfEdict()] 
got them with :
PHP Code:
#include <amxmodx>
#include <fakemeta>

new const crash_log[] = "hlds_crash.log"

public plugin_precache()
{
    
register_forward(FM_Sys_Error"fw_Sys_Error")
}

public 
fw_Sys_Error(const error[])
{
    
log_to_file(crash_log"Sys_Error: [%s]"error)

edit2:
i changed the fakemeta module of amxx "1.8.3-dev+5044" and replaced with with the one from amxx 1.8.2 and problem still exist.
__________________

Last edited by JusTGo; 04-02-2016 at 17:01.
JusTGo is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-02-2016 , 17:05   Re: amxx 1.8.3 code crash
Reply With Quote #6

Well, you hook as pre, meaning nothing are set in TraceResult yet, so it's possible (and expected) that mod/engine passes some address where memory was not initialized (basically you get garbage), and you get a crash because value is not null, but when engine tries to convert pHit edict to index, result is not a valid player's index. You would get a crash with any AMXX version.
__________________

Last edited by Arkshine; 04-02-2016 at 17:06.
Arkshine is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 04-02-2016 , 17:09   Re: amxx 1.8.3 code crash
Reply With Quote #7

i got the code from approved plugin and works with no problems on amxx 1.8.2. so hooking as post will not break plugin functionality and wont crash ?
__________________
JusTGo is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-02-2016 , 17:13   Re: amxx 1.8.3 code crash
Reply With Quote #8

I doubt that code tries to retrieve pHit in such forward as pre. Show me.

This is not a compatibility issue, this is expected it may crash because nothing is set in "trace" at this point. You can't retrieve data which doesn't exist yet.
__________________

Last edited by Arkshine; 04-02-2016 at 17:14.
Arkshine is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 04-02-2016 , 17:17   Re: amxx 1.8.3 code crash
Reply With Quote #9

https://forums.alliedmods.net/showthread.php?p=580384


PHP Code:
public fw_traceline(Float:start[3], Float:end[3], conditionsidtrace)
{
    
// Spectators don't need to run this.
    
if (!is_user_alive(id)) return FMRES_IGNORED
    
    
// If we hit a player, don't bother searching for an item nearby.
    
if (is_user_alive(get_tr2(traceTR_pHit))) return FMRES_IGNORED
    
    
static Float:endpt[3], tr 0i
    
    get_tr2
(traceTR_vecEndPosendpt)
    
    
0
    
    
while ((engfunc(EngFunc_FindEntityInSphereiendpt20.0)))
    {
        if (
is_shootable_ent(i))
        {
            
engfunc(EngFunc_TraceModelstartendHULL_POINTitr)
        
            if (
pev_valid(get_tr2(trTR_pHit)))
            {
                
get_tr2(trTR_vecEndPosendpt)
                
set_tr2(traceTR_vecEndPosendpt)
                
                
set_tr2(traceTR_pHiti)
                
                return 
FMRES_IGNORED
            
}
        }
    }
    
    return 
FMRES_IGNORED

__________________
JusTGo is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-02-2016 , 17:39   Re: amxx 1.8.3 code crash
Reply With Quote #10

Code could work if "trace" was equal to 0 because it's allowed to pass 0 with get_tr2(), it will retrieve from the global var but when you look at CS code source, it's unlikely.

His code is wrong, forward should be registered as post to be able to retrieve data from trace result. Supposing "trace" is 0, his code would be still wrong because global var is updated once trace line is done.
You can see other people getting a crash in 2009: https://forums.alliedmods.net/showpo...3&postcount=97
__________________
Arkshine 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 02:14.


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