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

Trace / breakpoint trap crash after plugin reload if extension has identical virtual hook #29

Open
nosoop opened this issue Nov 15, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@nosoop
Copy link

nosoop commented Nov 15, 2021

Took me a bit but I got this bug reproduced without hand-patched binary dependencies.

Dump available on Accelerator.

Steps to reproduce

  1. Have TF2Items and the provided plugin installed. The plugin can be late loaded.
  2. Connect a player. bot command works here.
  3. Reload the plugin.
  4. Add another player. Observed result is server crashing with a "Trace / breakpoint trap" message.
Source code
#pragma semicolon 1
#include <sourcemod>

#include <sdktools>
#include <dhooks>

#pragma newdecls required

Handle g_DHookGiveNamedItem;

public void OnPluginStart() {
	Handle hGameConf = LoadGameConfigFile("tf2.items");
	if (!hGameConf) {
		SetFailState("Failed to load gamedata (tf2.items).");
	}
	
	g_DHookGiveNamedItem = DHookCreate(GameConfGetOffset(hGameConf, "GiveNamedItem"),
			HookType_Entity, ReturnType_Unknown, ThisPointer_CBaseEntity,
			.callback = OnGivePlayerItemPre);
	DHookAddParam(g_DHookGiveNamedItem, HookParamType_CharPtr);
	DHookAddParam(g_DHookGiveNamedItem, HookParamType_Int);
	DHookAddParam(g_DHookGiveNamedItem, HookParamType_Int);
	DHookAddParam(g_DHookGiveNamedItem, HookParamType_Bool);
	
	delete hGameConf;
	
	for (int i = 1; i <= MaxClients; i++) {
		if (IsClientInGame(i)) {
			OnClientPutInServer(i);
		}
	}
	
}

public void OnClientPutInServer(int client) {
	DHookEntity(g_DHookGiveNamedItem, false, client);
}

MRESReturn OnGivePlayerItemPre(int client, Handle hReturn, Handle hParams) {
	return MRES_Ignored;
}
@peace-maker peace-maker added the bug Something isn't working label Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants