forked from realtime-sanitizer/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
DRAFT/PREVIEW --- [rtsan] Refactor where we get the stack #8
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//===--- rtsan_stats.cpp - Realtime Sanitizer -------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the RealtimeSanitizer runtime library | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "rtsan/rtsan_stats.h" | ||
|
||
#include "sanitizer_common/sanitizer_atomic.h" | ||
#include "sanitizer_common/sanitizer_common.h" | ||
|
||
using namespace __sanitizer; | ||
using namespace __rtsan; | ||
|
||
static atomic_uint32_t rtsan_total_error_count{0}; | ||
|
||
void __rtsan::IncrementTotalErrorCount() { | ||
atomic_fetch_add(&rtsan_total_error_count, 1, memory_order_relaxed); | ||
} | ||
|
||
static u32 GetTotalErrorCount() { | ||
return atomic_load(&rtsan_total_error_count, memory_order_relaxed); | ||
} | ||
|
||
void __rtsan::PrintStatisticsSummary() { | ||
ScopedErrorReportLock l; | ||
Printf("RealtimeSanitizer exit stats:\n"); | ||
Printf(" Total error count: %u\n", GetTotalErrorCount()); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//===--- rtsan_stats.h - Realtime Sanitizer ---------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the RealtimeSanitizer runtime library | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#pragma once | ||
|
||
namespace __rtsan { | ||
|
||
void IncrementTotalErrorCount(); | ||
|
||
void PrintStatisticsSummary(); | ||
|
||
} // namespace __rtsan |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// RUN: %clangxx -fsanitize=realtime %s -o %t | ||
// RUN: env RTSAN_OPTIONS="halt_on_error=false,print_stats_on_exit=true" %run %t 2>&1 | FileCheck %s | ||
|
||
// UNSUPPORTED: ios | ||
|
||
// Intent: Ensure exits stats are printed on exit. | ||
|
||
#include <unistd.h> | ||
|
||
void violation() [[clang::nonblocking]] { | ||
const int kNumViolations = 10; | ||
for (int i = 0; i < kNumViolations; i++) { | ||
usleep(1); | ||
} | ||
} | ||
|
||
int main() { | ||
violation(); | ||
return 0; | ||
} | ||
|
||
// CHECK: RealtimeSanitizer exit stats: | ||
// CHECK-NEXT: Total error count: 10 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// RUN: %clangxx -fsanitize=realtime %s -o %t | ||
// RUN: env RTSAN_OPTIONS="halt_on_error=false" %run %t 2>&1 | FileCheck %s | ||
// UNSUPPORTED: ios | ||
|
||
// Intent: Ensure that halt_on_error does not exit on the first violation. | ||
|
||
#include <stdlib.h> | ||
|
||
void *MallocViolation() { return malloc(10); } | ||
|
||
void FreeViolation(void *Ptr) { free(Ptr); } | ||
|
||
void process() [[clang::nonblocking]] { | ||
void *Ptr = MallocViolation(); | ||
FreeViolation(Ptr); | ||
} | ||
|
||
int main() { | ||
process(); | ||
return 0; | ||
// CHECK: ==ERROR: RealtimeSanitizer | ||
// CHECK-NEXT: {{.*`malloc`.*}} | ||
// CHECK: ==ERROR: RealtimeSanitizer | ||
// CHECK-NEXT: {{.*`free`.*}} | ||
} |
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.
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.
Getting the stack here is essential for deduplication. See the next change in the series here:
https://github.com/cjappl/llvm-project/pull/9/files#diff-26b1e9b52cc6bd23ad235825b8438ded1867285654d29b60536c5e87876adb3cR39-R46