Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on RCON gmx #280

Closed
ghost opened this issue Oct 16, 2018 · 8 comments
Closed

Crash on RCON gmx #280

ghost opened this issue Oct 16, 2018 · 8 comments
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Oct 16, 2018

server was crashed on try reload gamemode with rcon gmx

SA-MP Server: 0.3.7-R2

Exception At Address: 0x0047E047 Module: (samp-server.exe)

Registers:
EAX: 0x028000FE EBX: 0x000000FE ECX: 0x00000000 EDX: 0x00470000
ESI: 0x02874B0C EDI: 0x000F4726 EBP: 0x02870430 ESP: 0x0019F8DC
EFLAGS: 0x00010212

@ikkentim ikkentim added the crash label Oct 17, 2018
@ikkentim
Copy link
Owner

This was with hosted mode enabled?

@ikkentim
Copy link
Owner

Have not been able to reproduce this, do you have any additional info?

@sionzee
Copy link
Contributor

sionzee commented Nov 21, 2018

Occured to me, (fake) gmx works when server is empty but not when there is an one player.

When there is a player then server is crashing. This is last log before server crashes.

[04:19:04] [SampSharp:INFO] The gamemode is reconnecting.
[04:19:04] [SampSharp:INFO] Client disconnected.

Normal log is:

[04:16:51] [SampSharp:INFO] The gamemode is reconnecting.
[04:16:51] [SampSharp:INFO] Client disconnected.
[04:16:51]   Filterscript 'intermission.amx' loaded.
[04:16:51] [SampSharp:INFO] Creating pipe \\.\pipe\SampSharp...
[04:16:51] [SampSharp:INFO] Pipe created.
[04:16:51] [SampSharp:INFO] Client reconnected.
[04:16:51] [SampSharp:INFO] Server annoucement sent.
[04:16:51]   Filterscript 'intermission.amx' unloaded.
[04:16:51] [SampSharp:INFO] The gamemode has started.
[04:17:03] Number of vehicle models: 0

Tested on NetCore console application. Easy to reproduce.
Create a normal project, set StartBehavior to FakeGMX, start server, attach your gamemode. Connect to the server, spawn yourself. Go to console and write "gmx". Server crashes.

Program.cs

    new GameModeBuilder()
            .UseLogLevel(CoreLogLevel.Debug)
            .UseStartBehaviour(GameModeStartBehaviour.FakeGmx)
            .UseExitBehaviour(GameModeExitBehaviour.Restart)
            .Use<MyGameMode>()
            .Run();

MyGameMode.cs

    protected override void OnInitialized(EventArgs e)
    {
        Console.WriteLine("\n----------------------------------");
        Console.WriteLine(" Blank Gamemode by your name here");
        Console.WriteLine("----------------------------------\n");
        
        PlayerConnected += (sender, args) => {
            var player = (BasePlayer) sender;
            player.SendClientMessage("Message!");
        };

        /*
         * TODO: Do your initialisation and loading of data here.
         */
        base.OnInitialized(e);
    }

Using latest API source code from the master with SampPlugin from the latest release 0.8.0-alpha9.

@ikkentim
Copy link
Owner

Thanks for the info! This will help me track down the bug.

@ikkentim ikkentim added this to the 0.8.0 milestone Nov 21, 2018
@sionzee
Copy link
Contributor

sionzee commented Nov 22, 2018

The issue occurs when is called "set_on" in "intermission.cpp", I will post more info into this comment when I research something.

Crash is when doing

sampgdk_SendRconCommand("loadfs intermission")

Looking inside intermission.pwn and trying to find out what is happening
Message "The server is restarting.." is sent to the player (it is the last message what can client see)

Server crashes when is Destroying Player Resources.
Exactly these three lines:

/* Pools */
DESTROY_POOL_PFX(DestroyPlayerObject,MAX_PLAYER_OBJECTS-1,playerid);
DESTROY_POOL_PFX_TAG(PlayerTextDrawDestroy, MAX_PLAYER_TEXT_DRAWS-1,playerid,PlayerText:);
DESTROY_POOL_PFX_TAG(DeletePlayer3DTextLabel, MAX_3DTEXT_PLAYER-1,playerid,PlayerText3D:);

After more inspection the crash is happening here:

DESTROY_POOL_PFX_TAG(DeletePlayer3DTextLabel, MAX_3DTEXT_PLAYER-1,playerid,PlayerText3D:);

Maybe this could be the issue, when I'm joining to the server then I'm ID 0.
https://www.reddit.com/r/samp/comments/3cobpd/helpscriptingdeleteplayer3dtextlabel_crash_when/

Making more inspection

printf("DESTROY_POOL_PFX DestroyPlayerObject");
DESTROY_POOL_PFX(DestroyPlayerObject,MAX_PLAYER_OBJECTS-1,playerid);
printf("DESTROY_POOL_PFX_TAG PlayerTextDrawDestroy");
DESTROY_POOL_PFX_TAG(PlayerTextDrawDestroy, MAX_PLAYER_TEXT_DRAWS-1,playerid,PlayerText:);

Another interesting find out. It will print only the first one log but the second one is not printed.

I moved out functions from macros to better debug them

printf("DESTROY_POOL_PFX DestroyPlayerObject");
for(new di = MAX_PLAYER_OBJECTS - 1; di >= 0; di--){
	printf("DestroyPlayerObject with id %d", di);
	DestroyPlayerObject(playerid, _: di);
}

printf("DESTROY_POOL_PFX_TAG PlayerTextDrawDestroy");
for(new di = MAX_PLAYER_TEXT_DRAWS - 1; di >= 0; di--){
	printf("PlayerTextDrawDestroy with id %d", di);
	PlayerTextDrawDestroy(playerid, PlayerText: di);
}

printf("DESTROY_POOL_PFX_TAG DeletePlayer3DTextLabel");
for(new di = MAX_3DTEXT_PLAYER - 1; di >= 0; di--) {
	printf("DeletePlayer3DTextLabel with id %d", di);
	DeletePlayer3DTextLabel(playerid, PlayerText3D: di);
}

The only one result is:

[23:36:04] DESTROY_POOL_PFX DestroyPlayerObject
[23:36:04] DestroyPlayerObject with id 254

Then is following crash.

@htfranek
Copy link

htfranek commented Nov 22, 2018

I can indeed confirm this problem happens. Wierd that you weren't initially able to reproduce the issue as it occurs everytime you attempt rcon gmx unless you have intermissions off (which causes a whole lot of other issues).

@ikkentim
Copy link
Owner

Ah thanks! Yes I actually had intermissions off. There are a number of issues with intermissions/hot swapping. I'll fix this crash at the very least

@ikkentim
Copy link
Owner

Disabled player pool destroy functions in the intermission. I want to improve sampsharp's cleanup in the future anyway, the intermission filterscript doesn't seem to be the right way anyway. Also, it's only used when not in hosted mode, and hosted mode is the advised way of running the server in production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants