-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang-format] Optimize processing .clang-format-ignore files (#76733)
Reuse the patterns governing the previous input file being formatted if the current input file is from the same directory.
- Loading branch information
Showing
3 changed files
with
69 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
42ec976
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, looks like this broke
Format/clang-format-ignore.cpp
on most of the sanitizer buildbots (https://lab.llvm.org/buildbot/#/builders/5/builds/39794). Some of the buildbots were already broken due to 53edf12, so it's easy to miss the notification.On our aarch64-hwasan bot as well (https://lab.llvm.org/buildbot/#/builders/236/builds/8430), looks like additionally
Clang :: Format/multiple-inputs-inplace.cpp
was broken.Snippet below:
42ec976
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed that the runlines aren't particularly descriptive because stderr is captured to a file. Here's how I reproduced it locally, and the result is below:
42ec976
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static StringRef PrevDir
is a stringref toDir
(:602), which itself is a reference to the function-scopeString AbsPath
.The first time the function gets called,
PrevDir
is an empty reference. Then, it's set to a reference to the function scopeAbsPath
, then the function finishes up andPrevDir
is now dangling.The second time the function gets called,
PrevDir
gets dereferenced, and is a use-after-scope (a use-after-free in this case as the backing string is heap-allocated).42ec976
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hctim thanks a lot! I should have known better. I have relanded the patch as b53628a after changing the type of
PrevDir
toString
(i.e.SmallString<128>
).