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

Use a flag to prevent hashCode recursion in PyList or PyMap #1112

Merged
merged 3 commits into from
Aug 24, 2023

Conversation

jasmith-hs
Copy link
Contributor

Solves the same problem as #1111. This demonstrates a different approach where a semaphore is used to ensure that a PyList or PyMap cannot have hashCode() called for itself during its own hashCode() call.

Copy link
Collaborator

@mattcoley mattcoley left a comment

Choose a reason for hiding this comment

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

This would be the equivalent of turning a boolean on and off right? Any reason for the overhead of threadlocal/semaphore object vs. just using a boolean value.

@jasmith-hs
Copy link
Contributor Author

Oh yeah, I could make the semaphore just a boolean. ThreadLocal is to make sure that PyList and PyMap can still have correct hashCode when done async

@mattcoley
Copy link
Collaborator

Given these are non-concurrent collections do we need to necessarily guarantee multi-threaded support for this hashcode operation? None of the other operations have any kind of locking guarantee in this case. I guess someone could throw in a concurrent map into a pymap and try to use it across multiple threads but that seems pretty atypical for Jinjava use code.

@mattcoley mattcoley merged commit 15f33ad into master Aug 24, 2023
4 checks passed
@mattcoley mattcoley deleted the hashcode-stack-overflow branch August 24, 2023 13:59
@jasmith-hs jasmith-hs changed the title Use a ThreadLocal semaphore to prevent hashCode recursion Use a flag to prevent hashCode recursion in PyList or PyMap Aug 24, 2023
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.

2 participants