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

Race condition in Scanner ctor #158

Closed
mmimica opened this issue Sep 27, 2021 · 1 comment
Closed

Race condition in Scanner ctor #158

mmimica opened this issue Sep 27, 2021 · 1 comment

Comments

@mmimica
Copy link
Contributor

mmimica commented Sep 27, 2021

There is a race condition in Scanner constructor when counting the number of active Scanner instances.
The increment and decrement of counter in the constructor and close() are not atomic, leading to the wrong value being counted.

The variable should be AtomicInteger.

    public Scanner() {
        // <snip>
        count++;
    }
    @Override
    public void close() {
        scratch.close();
        matchHandler.close();
        count--;
        scratch = null;
    }
mmimica pushed a commit to mmimica/hyperscan-java that referenced this issue Sep 27, 2021
mmimica pushed a commit to mmimica/hyperscan-java that referenced this issue Sep 27, 2021
@mmimica
Copy link
Contributor Author

mmimica commented Sep 27, 2021

#159

mmimica pushed a commit to mmimica/hyperscan-java that referenced this issue Oct 18, 2021
mmimica pushed a commit to mmimica/hyperscan-java that referenced this issue Oct 18, 2021
gliwka pushed a commit to mmimica/hyperscan-java that referenced this issue Nov 20, 2023
gliwka pushed a commit to mmimica/hyperscan-java that referenced this issue Nov 20, 2023
@gliwka gliwka closed this as completed in 8b78da6 Nov 20, 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

No branches or pull requests

1 participant