Repository navigation
blktrace: fix three bugs in merge_blktrace_iologs path - #2099
Merged
Merged
Conversation
Collaborator
|
@wangxp006 would you be able to include a real name in front of your email address with the commit author/signed off by? @lukasstraub2 these changes look required to me after your commit 5ab088a - do you agree? |
Contributor
|
Yes, looks good to me from a quick look. |
1. fread pointer: pass the trace buffer pointer (t) instead of pointer to the pointer (&t), and use sizeof(*t) for the struct size instead of the pointer size. This caused "iolog short read" and made the merge path dead code. 2. stdio buffer use-after-free: fclose the merged file before freeing the custom stdio buffer set up via setvbuf. Previously free(merge_buf) was called while merge_fp still referenced it. 3. double free on merge success: read_iolog_file and merge_blktrace_file are both FIO_OPT_STR_STORE char pointers. Assigning one to the other made them point to the same memory, causing a double free when options_free frees both. Fix by transferring ownership and NULLing merge_blktrace_file. Reproduction: ./fio --name=merge --merge-blktrace-only --merge_blktrace_file=/tmp/result.log --merge_blktrace_scalars=100 --merge_blktrace_iters=1 --read_iolog=/data_disk6/randy/tmp/bt1.blktrace.220 Before fix: "iolog short read" error (Bug 1 makes merge dead code). After Bug 1 only: "double free or corruption (fasttop)" crash during put_job -> options_free, caused by Bugs 2 and 3 unmasked by Bug 1 fix. Signed-off-by: xiaopeng.wang <wangxp006@163.com>
Contributor
Author
I have already added the real name in front of the email address for the “Signed-off-by” line. |
Collaborator
|
@vincentkfu this looks good to me. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reproduction:
./fio --name=merge --merge-blktrace-only --merge_blktrace_file=/tmp/result.log --merge_blktrace_scalars=100 --merge_blktrace_iters=1 --read_iolog=/data_disk6/randy/tmp/bt1.blktrace.220
Before fix: "iolog short read" error (Bug 1 makes merge dead code).
After Bug 1 only: "double free or corruption (fasttop)" crash during
put_job -> options_free, caused by Bugs 2 and 3 unmasked by Bug 1
fix.