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

Data race in ConcurrentCharLoader.java #487

Open
spalac24 opened this issue Oct 19, 2021 · 0 comments
Open

Data race in ConcurrentCharLoader.java #487

spalac24 opened this issue Oct 19, 2021 · 0 comments

Comments

@spalac24
Copy link

Hi,

I believe I found a data race in ConcurrentCharLoader.java , which can be triggered by default normal use of the CsvParser library.

Here's a sample minimal code that triggers the issue: https://gist.github.com/spalac24/0256b40b1d6652fdb30e91624f7b5ed0

In short, that code causes stopReading() to be called both from https://github.com/uniVocity/univocity-parsers/blob/master/src/main/java/com/univocity/parsers/common/input/concurrent/ConcurrentCharLoader.java#L101 (which runs in its own thread by default) and https://github.com/uniVocity/univocity-parsers/blob/master/src/main/java/com/univocity/parsers/common/input/concurrent/ConcurrentCharInputReader.java#L85 concurrently, but stopReading() is not thread safe.

This does not reliably cause an exception to be thrown because repeatedly closing a Reader is fine as per the Java spec, but I believe it should still be addressed.

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