View Single Post
Author Message
Th3822
Member
Join Date: Jan 2013
Location: Venezuela
Old 04-23-2020 , 23:52   Weird error/crash after using server_cmd("stats") and server_exec() on a clcmd
Reply With Quote #1

I found this weird bug while testing a plugin (that i will be release soon(tm))

First, here is an example plugin for testing the issue:
PHP Code:
#include <amxmodx>

new const g_szMessage[] = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.^nMorbi condimentum ex eu arcu suscipit, ac sodales quam pulvinar.";

public 
plugin_init()
{
    
register_plugin("server_cmd(^"stats^");se""rver_exec("") bug/crash");
    
register_concmd("test""cmdTest");
    
register_concmd("test2""cmdTest2");
}

public 
cmdTest(id)
{
    
server_cmd("stats");
    
console_print(idg_szMessage);
    return 
PLUGIN_HANDLED;
}

public 
cmdTest2(id)
{
    
server_cmd("stats");
    
server_exec();
    
console_print(idg_szMessage);
    return 
PLUGIN_HANDLED;

When using "test", it works, stats is shown on server console and the message is printed on client's console.
But, when running "test2", at client side, the message is shown, but at server, it shows an extra error msg:
Code:
CPU   In    Out   Uptime  Users   FPS    Players
 0.00  2.40  1.62       0     1   57.29       1
SV_ReadClientMessage: badread
And it's not only that, after a couple of uses/minutes it randomly crashes the server.
Here is a message shown at the crash:
Code:
SV_ReadClientMessage: too many cmds 171 sent for /00000000:000000000000:0
L 04/19/2020 - 12:12:03: FATAL ERROR (shutting down): SZ_GetSpace:  Tried to write to an uninitialized sizebuf_t: ???
* I've noticed that the issue doesn't happen when i run "test2" from server's console, nor the error msg or the crash, it just happens when it's called by a client

* Issue happens even without the console_print, but server crashes quickly with it (< 3-5 min), so i did leave it

* I've already tested with 1.8.2 and a 1.9.0 build on windows [ cstrike ] (both HLDS/reHLDS), also with the same 1.9.0 build on linux with reHLDS, the issue is present on both.

* I've tested some other commands, but it only seems to happen with "stats"

btw, i really need the server_exec there, so deleting it's not an option.

Edit: Answer

Last edited by Th3822; 04-26-2020 at 20:48.
Th3822 is offline