This repository has been archived by the owner on Jun 23, 2022. It is now read-only.
fix(asan): heap-use-after-free caused by using string_view in fail_point #446
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.
Problem
It will crash because of
heap-use-after-free
when executedsn::fail::cfg("db_write_batch_put", "10%return()")
intest_batch_writes
ofpegasus_server_write_test.cpp
. The code ofpegasus_server
is test_batch_writes:Reason
The code call(line 107):
rdsn/src/core/core/fail_point.cpp
Lines 105 to 107 in a0ecf81
and crash at(line 353):
rdsn/include/dsn/utility/string_view.h
Lines 349 to 353 in a0ecf81
The root causes have two aspect:
string_view
class haschar *
member, but only supportshallow copying
sub_match.str()
will generatetemporary variable
and use thistemporary variable
to construct thestring_view
The actions just as follow:
Solution
The usage of
string_view
isn't right, we can usestd::string