-
Notifications
You must be signed in to change notification settings - Fork 639
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 with CFuncTank #2594
Comments
Plugins like Metamod can interfere with normal operation of games so i'd advise reporting issues occurring on vanilla servers only, or reproducing issues on vanilla servers if you've encountered them on modified servers. In cases like this reporting them anyway is a good thing since it seems to be happening regardless of plugins though. I looked into this and it seems that this line is causing it: Line 496 in c7240b9
The controller is non-null but invalid, i suspect the following scenario occurred:
Fixing it requires disconnecting clients to stop using func_tank. This should be done somewhere in here: Lines 97 to 136 in c7240b9
I would recommend moving this bit: Lines 120 to 133 in c7240b9
Into a new method:
And then calling it in This applies to all GoldSource engine games since they use the same code for tanks. |
@mikela-valve this must be fixed. It is an easy exploit to crash a server... |
On Pawn language, it had helped me already:
|
That plugin only works if there is only one func_tank in the map. |
Yeap. |
There is more than one type of func_tank, but if there is more than one func_tank entity instance it also won't work. Your code will make the first func_tank stop being controlled, even if the disconnecting player was using another tank. According to this: https://wiki.alliedmods.net/AMX_Mod_X_1.9_API_Changes You can use See documentation here: This should work with any number of func_tanks, regardless of type. |
Hm.. really, that's work just for a one. I have Amxx 1.8.2, 'cause I don't know why, but my Jb engine is falling from time to time with 1.9.0 without any reasons, instead of 1.8.2 . I think smth like that should be the solution for a several func_tank entities(not a great, but anyway..),
Hope it won't crash your server :) |
func_tank isn't the only name of that entity. Is m_pTank offset returning true or false only? The way you are currently using in the plugin can be improved a lot. |
is this fixed on rehlds / regamedll ? |
@RauliTop, I've done it simply for my server and there was just one thing for a using. U could do next for a several classes:
or make these checks of the classnames in a cycle one by one. I think the solution of @SamVanheer is the best with
@justgo97, I don't see in Re cleaning data with using tank, when a player is leaving the server. |
Impossible to reproduce it for me. This is what I tried:
I'm pretty sure there is a crash problem with this entities. I have blocked them at the past on my server because were doing crashes when players were using them constantly. Probably there's another way to produce the crash or I forgot something. @leonid9851 and @SamVanheer , did you test something? |
I tested this with a vanilla Half-Life SDK build and in that codebase it does stop controlling the tank because of this: Line 135 in c7240b9
halflife/dlls/multiplay_gamerules.cpp Line 501 in c7240b9
Lines 818 to 822 in c7240b9
However i don't see this code in Counter-Strike's version of I did some further testing and i found that disconnecting and reconnecting reallocated the I'm guessing the presence of Metamod and AMXMod resulted in additional memory allocations that alter the address and eventually causes the pointer to be invalid, resulting in a segfault. Re-adding the code to stop using tanks in |
Do you mean disconnecting and reconnecting the same player? Or is it the same for other player? The test I realized was in a server using Metamod and AMXModX |
The same player, but the engine just picks the first free slot. Getting the underlying memory allocator to return a different address requires you to leave a free chunk of memory that occurs earlier in the list of memory blocks so it's hard to get it to happen in an isolated test. |
So, the crash will happen only when a player disconnects and another player connects to his slot. Is that what you mean? |
You can reproduce the issue by allocating the original memory region to another temporary entity:
The first time you connect it allocates the original memory region to your player. This code will allocate the original memory region to a dummy player entity (it's a player to match the size in bytes, which ensures no part of the original region could be assigned to your player entity), allocates another region to your player entity, and frees the dummy. If you do this then the game will crash:
The line numbers are off by a few but it's the same code. Make sure to also check my notes above for disabling the code in |
I did one more test. Again crash was impossible to reproduce alone. I notice an important aspect, after disconnect and connect again using a func_tank:
So, it's true that func_tank doesn't reset when a player disconnects using it. |
Yeah it still copies your angles because the controller pointer points to your CBasePlayer instance. If you didn't modify the code (either in SDK or using Metamod/AMXMod) then it will pretty much always reuse the same memory region. If you use a pre and post hook for |
I finally reproduce the crash. We need two different players:
I made a plugin to fix it. I will later post at alliedmodders and edit here. |
@mikela-valve seems that it was an attempt to fix this or something related: https://steamcommunity.com/games/70/announcements/detail/2199168953960582492 But the bug stills there. Should be solved on Next release because can cause server crash. |
I've fixed this issue like this: It also accounts for the possibility that the player CBaseEntity instance is null (if the player connects and immediately disconnects there could be a small window where this can happen). |
Hi there! There's a problem with gamedll, hope u could fix this.
So, let's start :
Build version of hlds is 7882
Modules list:
Crash log:
The text was updated successfully, but these errors were encountered: