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

LineReader buffer race condition with AsynchronousReader #36

Closed
llchan opened this issue Feb 17, 2017 · 3 comments
Closed

LineReader buffer race condition with AsynchronousReader #36

llchan opened this issue Feb 17, 2017 · 3 comments

Comments

@llchan
Copy link

llchan commented Feb 17, 2017

When the LineReader destructor is called, it frees the data buffer. However, there can be an in-flight read call in the AsynchronousReader worker thread, which will try to put stuff into the freed data buffer. This leads to a segfault. To reproduce, read a large file and throw an exception while it is reading.

The solution is simple: don't deallocate the buffer until the reader is joined. I have a PR I can send over, which basically replaces the char* buffer with a std::vector<char> buffer and puts that before the AsynchronousReader reader in the class members so that it gets destructed after the reader is destroyed.

@ben-strasser
Copy link
Owner

ben-strasser commented Feb 17, 2017 via email

@llchan
Copy link
Author

llchan commented Feb 17, 2017

Looks good to me! Thanks for the quick turnaround.

@ben-strasser
Copy link
Owner

Hi,

I just committed the patch. Thanks for reporting.

Best Regards
Ben Strasser

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

2 participants