GH-48311: [C++] Fix OOB memory access in buffered IO#48322
GH-48311: [C++] Fix OOB memory access in buffered IO#48322mapleFU merged 6 commits intoapache:mainfrom
Conversation
|
|
|
@wgtmac Hi, I don't know who to ping, so I chose you since you’ve looked at one of my reviews. Can you suggest the right person to call to review this? This bug is really annoying and appears very randomly (and looks like a corrupted allocator, so it's hard to debug). |
|
cc @mapleFU |
| // No need to reserve space for more than the total remaining number of bytes. | ||
| if (bytes_buffered_ == 0) { | ||
| // Special case: we can not keep the current buffer because it does not | ||
| // Special case: we can override data in the current buffer because it does not |
There was a problem hiding this comment.
Can you rewrite comment in SetBufferSize? Since buffer_pos_ would be rewritten now
There was a problem hiding this comment.
Missed that comment, thanks, fixed
|
@pitrou Would you mind take a look? Otherwise would merge if no objection next Tuesday |
|
After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit fb0bac6. There weren't enough matching historic benchmark results to make a call on whether there were regressions. The full Conbench report has more details. |
### Rationale for this change Fixing: #48311 ### What changes are included in this PR? Applied fix from #48311 and added test ### Are these changes tested? Yes, added test, without my patch test fails with debug check: ```cpp Note: Google Test filter = TestBufferedInputStream.PeekAfterExhaustingBuffer [==========] Running 1 test from 1 test suite. [----------] Global test environment set-up. [----------] 1 test from TestBufferedInputStream [ RUN ] TestBufferedInputStream.PeekAfterExhaustingBuffer /Users/chegoryu/Junk/git/arrow/cpp/src/arrow/io/buffered.cc:337: Check failed: buffer_->size() - buffer_pos_ >= nbytes ``` ### Are there any user-facing changes? No, this PR fixes a bug * GitHub Issue: #48311 Lead-authored-by: Egor Chunaev <ch.egor.yu@gmail.com> Co-authored-by: mwish <maplewish117@gmail.com> Co-authored-by: chegoryu <ch.egor.yu@gmail.com> Signed-off-by: mwish <maplewish117@gmail.com>
Rationale for this change
Fixing: #48311
What changes are included in this PR?
Applied fix from #48311 and added test
Are these changes tested?
Yes, added test, without my patch test fails with debug check:
Are there any user-facing changes?
No, this PR fixes a bug