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

Is this a bug or a new feature about passing an array into TR filter in sm1.13? #1016

Open
Miuwiki opened this issue Dec 14, 2024 · 2 comments
Labels
bug compiler Problems with the compiler parsing source code.

Comments

@Miuwiki
Copy link

Miuwiki commented Dec 14, 2024

Version info:
SourceMod Version: 1.13.0.7168
Metamod:Source version 2.0.0-dev+1314

The page show this code work fine but my friend said that it's not safe beacuase it maybe a bug actually.
I have test array int and enum struct. Both of them work fine.

f
g
h

@Malifox
Copy link

Malifox commented Dec 15, 2024

This actually seems to be a bug. any shouldn't accept an array as an argument and doesn't in 1.11. I'd guess it works here because the enum struct is passed by reference and won't be cleaned up until after the function it is declared in has finished, which will be after TR_TraceRayFilterEx has finished using it. An example of where this is not fine, but is also currently allowed by the compiler would be:

enum struct Test
{
	int a;
	float b;
}

public void OnPluginStart()
{
	Test test = {1, 2.0};

	RequestFrame(Frame_Test, test);
}

void Frame_Test(Test test)
{
	PrintToServer("a: %d, b: %f", test.a, test.b);
}

This now compiles without error, but crashes the server as the enum struct will not exist by then.

@peace-maker peace-maker transferred this issue from alliedmodders/sourcemod Dec 15, 2024
@peace-maker peace-maker added bug compiler Problems with the compiler parsing source code. labels Dec 15, 2024
@Miuwiki
Copy link
Author

Miuwiki commented Dec 16, 2024

i didn't crash my server when passing enum struct in timer and RequestFrame, but it's value will become strange and looks like it point to an unsafe memory in game.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug compiler Problems with the compiler parsing source code.
Projects
None yet
Development

No branches or pull requests

3 participants