Skip to content

StreamPollFeeder.done should be volatile (thread may hang) #385

Closed

Description

@elharo

StreamPollFeeder.done (line 40) is not declared volatile, but is read in run() outside any synchronized block (line 61) while being written in waitUntilDone() inside synchronized (lock) (line 107).

When the run() thread is actively reading data (input.available() > 0 is continuously true), it never enters the synchronized (lock) block where the lock's happens-before would provide visibility. So waitUntilDone() setting done = true may never be seen by the run() thread, causing it to loop forever — and waitUntilDone()'s subsequent join() call hangs too.

Fix: declare done as volatile.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions