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

Invoking a native while inside a native callback will result in a preemptive cleanup. #501

Closed
Poggicek opened this issue Jun 15, 2024 · 0 comments
Labels
area-Core-ScriptEngine untriaged New issue has not been triaged

Comments

@Poggicek
Copy link
Contributor

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]
}

[SecuritySafeCritical]
public void Invoke()
{
InvokeNativeInternal();
GlobalCleanUp();
}

@github-actions github-actions bot added the untriaged New issue has not been triaged label Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Core-ScriptEngine untriaged New issue has not been triaged
Projects
None yet
Development

No branches or pull requests

2 participants