Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[scudo] 32-bit quarantine sizes adjustments and bug fixes
Summary: The local and global quarantine sizes were not offering a distinction for 32-bit and 64-bit platforms. This is addressed with lower values for 32-bit. When writing additional tests for the quarantine, it was discovered that when calling some of the allocator interface function prior to any allocation operation having occured, the test would crash due to the allocator not being initialized. This was addressed by making sure the allocator is initialized for those scenarios. Relevant tests were added in interface.cpp and quarantine.cpp. Last change being the removal of the extraneous link dependencies for the tests thanks to rL293220, anf the addition of the gc-sections linker flag. Reviewers: kcc, alekseyshl Reviewed By: alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29341 llvm-svn: 294037
- Loading branch information
Kostya Kortchinsky
committed
Feb 3, 2017
1 parent
90505a0
commit 8d6257b
Showing
18 changed files
with
143 additions
and
125 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,47 @@ | ||
// RUN: %clang_scudo %s -lstdc++ -o %t | ||
// RUN: %run %t 2>&1 | ||
// RUN: %run %t ownership 2>&1 | ||
// RUN: %run %t ownership-and-size 2>&1 | ||
// RUN: %run %t heap-size 2>&1 | ||
|
||
// Tests that the sanitizer interface functions behave appropriately. | ||
|
||
#include <stdlib.h> | ||
#include <assert.h> | ||
#include <string.h> | ||
|
||
#include <vector> | ||
|
||
#include <sanitizer/allocator_interface.h> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
void *p; | ||
std::vector<ssize_t> sizes{1, 8, 16, 32, 1024, 32768, | ||
1 << 16, 1 << 17, 1 << 20, 1 << 24}; | ||
for (size_t size : sizes) { | ||
p = malloc(size); | ||
if (!p) | ||
return 1; | ||
if (!__sanitizer_get_ownership(p)) | ||
return 1; | ||
if (__sanitizer_get_allocated_size(p) < size) | ||
return 1; | ||
free(p); | ||
assert(argc == 2); | ||
|
||
if (!strcmp(argv[1], "ownership")) { | ||
// Ensures that __sanitizer_get_ownership can be called before any other | ||
// allocator function, and that it behaves properly on a pointer not owned | ||
// by us. | ||
assert(!__sanitizer_get_ownership(argv)); | ||
} | ||
if (!strcmp(argv[1], "ownership-and-size")) { | ||
// Tests that __sanitizer_get_ownership and __sanitizer_get_allocated_size | ||
// behave properly on chunks allocated by the Primary and Secondary. | ||
void *p; | ||
std::vector<ssize_t> sizes{1, 8, 16, 32, 1024, 32768, | ||
1 << 16, 1 << 17, 1 << 20, 1 << 24}; | ||
for (size_t size : sizes) { | ||
p = malloc(size); | ||
assert(p); | ||
assert(__sanitizer_get_ownership(p)); | ||
assert(__sanitizer_get_allocated_size(p) >= size); | ||
free(p); | ||
} | ||
} | ||
if (!strcmp(argv[1], "heap-size")) { | ||
// Ensures that __sanitizer_get_heap_size can be called before any other | ||
// allocator function. At this point, this heap size should be 0. | ||
assert(__sanitizer_get_heap_size() == 0); | ||
} | ||
|
||
return 0; | ||
} |
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
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
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
Oops, something went wrong.