AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Run Time Error (https://forums.alliedmods.net/showthread.php?t=276206)

Depresie 12-17-2015 09:46

[HELP] Run Time Error
 
Code:

L 12/16/2015 - 22:13:16: Start of error session.
L 12/16/2015 - 22:13:16: Info (map "zm_extreme_fixed") (file "addons/amxmodx/logs/error_20151216.log")
L 12/16/2015 - 22:13:16: [AMXX] Displaying debug trace (plugin "zp50_objective_remover.amxx")
L 12/16/2015 - 22:13:16: [AMXX] Run time error 7: stack low
L 12/16/2015 - 22:13:16: [AMXX] Displaying debug trace (plugin "zp50_objective_remover.amxx")
L 12/16/2015 - 22:13:16: [AMXX] Run time error 7: stack low
L 12/16/2015 - 22:13:16: [AMXX] Displaying debug trace (plugin "zp50_objective_remover.amxx")
L 12/16/2015 - 22:13:16: [AMXX] Run time error 7: stack low

any ideea?

PHP Code:

/*================================================================================
    
    ------------------------------
    -*- [ZP] Objective Remover -*-
    ------------------------------
    
    This plugin is part of Zombie Plague Mod and is distributed under the
    terms of the GNU General Public License. Check ZP_ReadMe.txt for details.
    
================================================================================*/

#include <amxmodx>
#include <fakemeta>
#include <amx_settings_api>
#include <zp50_core_const>

// Settings file
new const ZP_SETTINGS_FILE[] = "zombieplague.ini"

new const objective_ents[][] = { "func_bomb_target" "info_bomb_target" "info_vip_start" "func_vip_safetyzone" "func_escapezone" "hostage_entity" "monster_scientist" "func_hostage_rescue" "info_hostage_rescue" }

#define CLASSNAME_MAX_LENGTH 32

new Array:g_objective_ents

new g_fwSpawn
new g_fwPrecacheSound

public plugin_init()
{
    
register_plugin("[ZP] Objective Remover"ZP_VERSION_STRING"ZP Dev Team")
    
unregister_forward(FM_Spawng_fwSpawn)
    
unregister_forward(FM_PrecacheSoundg_fwPrecacheSound)
    
register_forward(FM_EmitSound"fw_EmitSound")
    
register_message(get_user_msgid("Scenario"), "message_scenario")
    
register_message(get_user_msgid("HostagePos"), "message_hostagepos")
}

public 
plugin_precache()
{
    
// Initialize arrays
    
g_objective_ents ArrayCreate(CLASSNAME_MAX_LENGTH1)
    
    
// Load from external file
    
amx_load_setting_string_arr(ZP_SETTINGS_FILE"Objective Entities""OBJECTIVES"g_objective_ents)
    
    
// If we couldn't load from file, use and save default ones
    
new index
    
if (ArraySize(g_objective_ents) == 0)
    {
        for (
index 0index sizeof objective_entsindex++)
            
ArrayPushString(g_objective_entsobjective_ents[index])
        
        
// Save to external file
        
amx_save_setting_string_arr(ZP_SETTINGS_FILE"Objective Entities""OBJECTIVES"g_objective_ents)
    }
    
    
// Fake Hostage (to force round ending)
    
new ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"hostage_entity"))
    if (
pev_valid(ent))
    {
        
engfunc(EngFunc_SetOriginentFloat:{8192.0,8192.0,8192.0})
        
dllfunc(DLLFunc_Spawnent)
    }
    
    
// Prevent objective entities from spawning
    
g_fwSpawn register_forward(FM_Spawn"fw_Spawn")
    
    
// Prevent hostage sounds from being precached
    
g_fwPrecacheSound register_forward(FM_PrecacheSound"fw_PrecacheSound")
}

// Entity Spawn Forward
public fw_Spawn(entity)
{
    
// Invalid entity
    
if (!pev_valid(entity))
        return 
FMRES_IGNORED;
    
    
// Get classname
    
new classname[32], objective[32], size ArraySize(g_objective_ents)
    
pev(entitypev_classnameclassnamecharsmax(classname))
    
    
// Check whether it needs to be removed
    
new index
    
for (index 0index sizeindex++)
    {
        
ArrayGetString(g_objective_entsindexobjectivecharsmax(objective))
        
        if (
equal(classnameobjective))
        {
            
engfunc(EngFunc_RemoveEntityentity)
            return 
FMRES_SUPERCEDE;
        }
    }
    
    return 
FMRES_IGNORED;
}

// Sound Precache Forward
public fw_PrecacheSound(const sound[])
{
    
// Block all those unneeeded hostage sounds
    
if (equal(sound"hostage"7))
        return 
FMRES_SUPERCEDE;
    
    return 
FMRES_IGNORED;
}

// Emit Sound Forward
public fw_EmitSound(idchannel, const sample[], Float:volumeFloat:attnflagspitch)
{
    
// Block all those unneeeded hostage sounds
    
if (sample[0] == 'h' && sample[1] == 'o' && sample[2] == 's' && sample[3] == 't' && sample[4] == 'a' && sample[5] == 'g' && sample[6] == 'e')
        return 
FMRES_SUPERCEDE;
    
    return 
FMRES_IGNORED;
}

// Block hostage HUD display
public message_scenario()
{
    if (
get_msg_args() > 1)
    {
        new 
sprite[8]
        
get_msg_arg_string(2spritecharsmax(sprite))
        
        if (
equal(sprite"hostage"))
            return 
PLUGIN_HANDLED;
    }
    
    return 
PLUGIN_CONTINUE;
}

// Block hostages from appearing on radar
public message_hostagepos()
{
    return 
PLUGIN_HANDLED;



Chihuahuax 12-17-2015 11:11

Re: [HELP] Run Time Error
 
Debugged?

Depresie 12-17-2015 14:28

Re: [HELP] Run Time Error
 
unfortenatly yes....

addons_zz 12-17-2015 16:24

Re: [HELP] Run Time Error
 
These are the functions that throw AMX_ERR_STACKLOW ( Run time error 7: stack low ) which is know as /* stack underflow */ at amxmodx\amx.h:

At amxmodx\amx.cpp and amxxpc\amx.cpp it is used to composed define function.
PHP Code:

Line 1635#define CHKSTACK()      if (stk>amx->stp) return AMX_ERR_STACKLOW
Line 1661#define CHKSTACK()      if (stk>amx->stp) return AMX_ERR_STACKLOW 

At plugins\include\amxconst.inc its code number is know as 7
PHP Code:

#define AMX_ERR_STACKLOW    7 

The defined function CHKSTACK() is used at compiler\amxxpc\amx.cpp and amxmodx\amx.cpp functions and lines:
PHP Code:

Line 1645int AMXAPI amx_Exec(AMX *amxcell *retvalint index)
Line 2661int AMXAPI amx_Exec(AMX *amxcell *retvalint index)

Line 1671int AMXAPI amx_Exec(AMX *amxcell *retvalint index)
Line 2609int AMXAPI amx_Exec(AMX *amxcell *retvalint index)

    
Line 1752:   CHKSTACK();
    
Line 2050:     CHKSTACK();
    
Line 2745:   CHKSTACK();
    
Line 3085:       CHKSTACK();

    
Line 1774:   CHKSTACK();
    
Line 2072:     CHKSTACK();
    
Line 2704:   CHKSTACK();
    
Line 3043:       CHKSTACK(); 

End of history, I could not do a backtrack because it went crazy at amx_Exec. Then Let us apply this technique, but now a little different because do we have a new context, a mysterious low stack error.

First things first, I could not reproduce you error :(

How to reproduce you error?

After know it for sure how to reproduce it, remove some functionality from this plugin, then:

1) test if it still throwing that exception.

If not, you are closer to find the problem, and add some functionality back then go to 1)

If yes, remove some functionality again, then go to 1)

Repeat until you discover which line is throwing that Run time error 7. And after find which line, goes through your amxmodx implementation and find out why that line is throwing that exception, as did here.

To maybe guide better the search, the stack underflow error is an error that occurs when an item is called from the stack, but the stack is empty.

So we could think about what uses stacks at this plugin source code and take a close look at it while searching.

Depresie 12-17-2015 16:38

Re: [HELP] Run Time Error
 
problem is, it is the first time in 6 months when i get this error..
also, could anyone explain to me exactly what this plugin is doing?
from what i see, it removes the hostages, and the map's goal... right? but if the maps are made for zombie plague, there is no need for such thing, or am i wrong?

addons_zz 12-17-2015 17:29

Re: [HELP] Run Time Error
 
Quote:

Originally Posted by Depresie (Post 2373348)
problem is, it is the first time in 6 months when i get this error..
also, could anyone explain to me exactly what this plugin is doing?
from what i see, it removes the hostages, and the map's goal... right? but if the maps are made for zombie plague, there is no need for such thing, or am i wrong?

Yes. At least looks like, In-deeded its name is "Objective Remover".

So you cannot reproduce the error any time you want?

And as this is a ZP, is there a specialized forum and original thread where this plugin came from and provide support?


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

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