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

AudioStreamCallback design prone to race conditions #820

Closed
philburk opened this issue Apr 15, 2020 · 1 comment · Fixed by #821
Closed

AudioStreamCallback design prone to race conditions #820

philburk opened this issue Apr 15, 2020 · 1 comment · Fixed by #821
Assignees

Comments

@philburk
Copy link
Collaborator

The AudioStreamCallback contains a raw AudioStream pointer, which it passes to its callback methods.

If the onErrorBeforeClose() method has a delay, then there can be a large a window where the AudioStream could be closed and deleted by another thread, perhaps by user interaction. The AudioStreamCallback will then crash when it tries to close the stream.

The delete must not occur while the AudioStreamCallback is active. This is complicated by the fact that the AudioStreamCallback launches a separate thread to do the closing.

Perhaps the OboeStream destructor could join() the closing thread in the AudioStreamCallback.

Or a shared pointer could be used to defer the actual deletion. And that shared pointer could be passed to the AudioStreamCallback.

@philburk philburk self-assigned this Apr 15, 2020
@philburk
Copy link
Collaborator Author

A crash can be reproduced by adding:

usleep(2000 * 1000);

at the end of OboeStreamCallbackProxy::onErrorBeforeClose() in OboeTester,
then running TEST DISCONNECT.

philburk added a commit that referenced this issue Apr 15, 2020
To prevent race conditions with the onError callbacks
that were resulting in the use of a deleted stream.

For bug #820
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 a pull request may close this issue.

1 participant