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

Fix leaking array ref in Random #2972

Merged

Conversation

catostrophe
Copy link
Contributor

There's a bug in cats.effect.std.Random impl. In some cases nextBytes returns a ref to the same array. The bug is demonstrated in the newly added tests.

N.B. I changed the impl of both ThreadLocalRandom and ScalaRandom, although the bug appears only in the former. ScalaRandom works fine due to a delay in a preliminary flatMap before array creation. But I made the code identical to ThreadLocalRandom as to prevent the wrong pattern from being blindly copied somewhere else.

@djspiewak
Copy link
Member

Excellent catch! Should we be targeting this at series/3.3.x so we can release it sooner, though?

@catostrophe
Copy link
Contributor Author

Yes, shall I change the target branch?

@armanbilge
Copy link
Member

Yep, you'll also probably have to rebase and force-push :)

@catostrophe catostrophe changed the base branch from series/3.x to series/3.3.x April 27, 2022 03:26
@catostrophe
Copy link
Contributor Author

Done. The build has failed on some unrelated (flaky?) js test. Could you restart?

@armanbilge armanbilge closed this Apr 27, 2022
@armanbilge armanbilge reopened this Apr 27, 2022
Copy link
Member

@armanbilge armanbilge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@djspiewak djspiewak merged commit b1e4d2a into typelevel:series/3.3.x Apr 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants