View Single Post
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-01-2017 , 15:31   Re: amxx 1.8.3 code crash
Reply With Quote #12

A stack error in this context is likely caused by an infinite loop.

I can reproduce it with this code:

Code:
#include <amxmodx> public plugin_init() {      register_message(get_user_msgid("ShowMenu"), "OnShowMenu")      register_menucmd(register_menuid("Register System Main Menu"), 1023, "HandlerMainMenu") } public OnShowMenu(msgid, dest, id) {     static menu_text[64];     get_msg_arg_string(4, menu_text, charsmax(menu_text))     if (contain(menu_text, "#Team_Select") >= 0)     {         MainMenu(id)         return PLUGIN_HANDLED;     }     return PLUGIN_CONTINUE; } public MainMenu(id) {     show_menu(id, MENU_KEY_1|MENU_KEY_0, "1. My Item", -1, "Register System Main Menu"); } public HandlerMainMenu(id, key) {     if (++key == 1)     {         MainMenu(id);     }     return PLUGIN_HANDLED; }

It's a side-effect of https://bugs.alliedmods.net/show_bug.cgi?id=3199. "show_menu" and "menu_display" closes the currently viewed menu by sending "menuselect 10" on the client. But in CS, at this point (when a player is not yet fully joined), it will ignore this command, and the game will resend a "#Team_Select" message, then the plugin will hook ShowMenu again, sends "show_menu" native, then "menuselect 10", etc. Infinite loop.
__________________

Last edited by Arkshine; 12-01-2017 at 18:44.
Arkshine is offline