Skip to content

Fix Enum::from/tryFrom memory leak in JIT #8633

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

Conversation

iluuu1994
Copy link
Member

when passing an int to a string enum. Previously, the int was coerced to
a string. The JIT skips parameter clean up when unnecessary. In this
particular case, passing int to from(int|string) normally doesn't cause
a coercion so no dtor for the $value zval is generated.

To circumvent this we avoid coersion by explicitly allowing ints and
converting them to strings ourselves. Then we can free it appropriately.

See GH-8518

@iluuu1994 iluuu1994 force-pushed the fix-jit-enum-from-string-coercion-memory-leak branch 2 times, most recently from b8a93c5 to 8572533 Compare May 25, 2022 21:22
when passing an int to a string enum. Previously, the int was coerced to
a string. The JIT skips parameter clean up when unnecessary. In this
particular case, passing int to from(int|string) normally doesn't cause
a coercion so no dtor for the $value zval is generated.

To circumvent this we avoid coersion by explicitly allowing ints and
converting them to strings ourselves. Then we can free it appropriately.

See phpGH-8518
@iluuu1994 iluuu1994 force-pushed the fix-jit-enum-from-string-coercion-memory-leak branch from 8572533 to 17e3c42 Compare May 25, 2022 21:24
@iluuu1994 iluuu1994 closed this in 93fc88e May 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants