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

Concurrency problem with _lastline in LCDSocketPoller #4

Open
antoneliasson opened this issue Sep 17, 2016 · 1 comment
Open

Concurrency problem with _lastline in LCDSocketPoller #4

antoneliasson opened this issue Sep 17, 2016 · 1 comment

Comments

@antoneliasson
Copy link
Collaborator

antoneliasson commented Sep 17, 2016

I've observed crashes like the following:

sep 17 11:08:19 raspberrypi java[537]: Exception in thread "Thread-1" java.lang.NullPointerException
sep 17 11:08:19 raspberrypi java[537]: at java.util.regex.Matcher.getTextLength(Matcher.java:1283)
sep 17 11:08:19 raspberrypi java[537]: at java.util.regex.Matcher.reset(Matcher.java:309)
sep 17 11:08:19 raspberrypi java[537]: at java.util.regex.Matcher.<init>(Matcher.java:229)
sep 17 11:08:19 raspberrypi java[537]: at java.util.regex.Pattern.matcher(Pattern.java:1093)
sep 17 11:08:19 raspberrypi java[537]: at org.boncey.lcdjava.LCDSocketPoller.run(LCDSocketPoller.java:90)
sep 17 11:08:19 raspberrypi java[537]: [main] INFO org.boncey.lcdjava.LCD - Connected

Looking inside LCDSocketPoller, it's clear that access to _lastline is not concurrency correct. A different thread (inside LCD) can call getLastLine, setting it to null, while the LCDSocketPoller thread is reading _lastline inside the run() loop. This can cause it to be equal to null on line 90, even though there is a not-null-check on line 87.

Using org.boncey.lcdjava 0.5.0

@antoneliasson
Copy link
Collaborator Author

Work on this has started in the dev branch.

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