Invoking a native while inside a native callback will result in a preemptive cleanup.
As discussed in https://discord.com/channels/1160907911501991946/1215025384752681081/1215026288151240704 calling a native in any callback called by native c++ will cleanup the global context resources which may be used by the callback itself.
In the case that InvokeNativeInternal happens to loop back to Invoke (calling a native in a native [callbacks]) it shouldn't call the GlobalCleanUp as it will be called as soon as that InvokeNativeInternal finishes, doing so would cleanup any resources (e.g. strings) before the original native finishes.
For example if we have a hook that has a string param and we call any native inside the hook, the string will become corrupted after that native call.
hook(string str)
{
// str is valid
KickPlayer();
// str is free'd [BAD]
}
https://github.com/roflmuffin/CounterStrikeSharp/blob/2eaf7c2d8c7ab0810ed87756ac5f6c1cf6d756e4/managed/CounterStrikeSharp.API/Core/ScriptContext.cs#L100-L105