-
Notifications
You must be signed in to change notification settings - Fork 13
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
Superceding in one function prevents execution of post-callbacks up the call chain #2
Comments
The "fix crash" commit was causing some hooks to leak memory like crazy. |
It's weird though. EndContext should by called by the hookmanager generator in sourcehook. Maybe there's a bug in SourceHook or we're using it wrong, but I don't think calling EndContext ourself is the right fix? |
I think you might be right, I was only seeing the memory leak with the gamerules radiushurt (napalm lag fix) hook. |
But popping the stack more than you pushed it won't work. |
True, EndContext calls: |
You're talking about this plugin which caused the context stack to explode on your server, right? I think the issue nosoop is describing comes from the context stack not being popped and the MRES_SUPERCEDE return getting reused by the parent hook. It's weird, that it skips the post callback even after calling the original function that way. I guess only some nasty debugging will shed some light here. I don't have any time for this right now. |
Yeah, we had a good laugh too because a "Lag Fix" plugin was causing extreme server lag :^) @nosoop can you compile dhooks yourself? |
@BotoX Can do. Tried your repo compiled against 1.10 with the development instance described in the initial post (with a large number of dhooks/detour-using plugins) and it immediately crashes on player spawn, accelerator dumps 1, 2. 2.2.0-detours14a doesn't crash on spawn, but I can verify that it is also affected by the supercede bug. That's all from a cursory test; if you'd like any further actions taken let me know and I can look into it more when time permits. |
@nosoop Can you test with only the virtual hook plugin attached in the first comment loaded? That crash is from a detour which uses a completely different system from SourceHook which is used by sdkhooks and dhooks alike. |
In hindsight I should've tested that sooner, yeah. It looks like I indeed can't reproduce the supercede issue on a build from that repo, nor can I reproduce it on detours14a with an extra commit to revert 69b433c. The latter also works on my plugin-filled development instance, though I'm not thoroughly testing for regressions there. |
We setup a Recall (changing the parameters of the called function from within the hook handler) when a plugin wants to supercede, but never call the function again. This causes a copy of the current context to be pushed, but never properly removed by actually calling the function. This is wrong, since the original function should be skipped, so don't setup a Recall in SourceHook. This fixes a long standing issue causing a growth of the internal context stack in SourceHook. This caused very long delays on unhook during iteration of the context stack. Another issue was that the hook result further up the call stack would be misaligned due to the additional unused context pushed in DoRecall. Drifter321#2
This was fixed in peace-maker@314f926. It appears to be a misuse of SourceHook's API on our side. We're pushing an extra context onto the context stack when we shouldn't on supercede of non vector or float returns. So adding a bunch of |
Closing this since it's fixed in the version of DHooks bundled with SourceMod. |
ℹ️ This should no longer be an issue if you're using @peace-maker's version with detour support, but the issue will remain open as long as the issue is valid upstream.
Versions installed:
Hard to explain, so here's an example case.
Attached below is a plugin that uses a virtual hook on
CBaseCombatWeapon::PrimaryAttack()
and a post-hook onPostThink
via SDKHooks. If the hook on::PrimaryAttack()
returnsMRES_Supercede
, thePostThinkPost
callback never executes.To reproduce, install the plugin, set
test_supercede_bug
to 1, and shoot gun. The expected result is that the SourceMod continues to callPostThink
with the latest game time while attacking; the current behavior is that no messages are displayed.Only TF2 gamedata is provided, but the calls aren't specific to TF2.
test_dhook_think_func.zip
The text was updated successfully, but these errors were encountered: