Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: sandbox/win/src/address_sanitizer_test.cc

Issue 1518823002: Use volatile to prevent heap-to-stack promotion in an ASan test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdio.h> 5 #include <stdio.h>
6 6
7 #include "base/environment.h" 7 #include "base/environment.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 22 matching lines...) Expand all
33 protected: 33 protected:
34 scoped_ptr<base::Environment> env_; 34 scoped_ptr<base::Environment> env_;
35 bool had_asan_options_; 35 bool had_asan_options_;
36 std::string old_asan_options_; 36 std::string old_asan_options_;
37 }; 37 };
38 38
39 SBOX_TESTS_COMMAND int AddressSanitizerTests_Report(int argc, wchar_t** argv) { 39 SBOX_TESTS_COMMAND int AddressSanitizerTests_Report(int argc, wchar_t** argv) {
40 // AddressSanitizer should detect an out of bounds write (heap buffer 40 // AddressSanitizer should detect an out of bounds write (heap buffer
41 // overflow) in this code. 41 // overflow) in this code.
42 volatile int idx = 42; 42 volatile int idx = 42;
43 int *blah = new int[42]; 43 int *volatile blah = new int[42];
44 blah[idx] = 42; 44 blah[idx] = 42;
45 delete [] blah; 45 delete [] blah;
46 return SBOX_TEST_FAILED; 46 return SBOX_TEST_FAILED;
47 } 47 }
48 48
49 TEST_F(AddressSanitizerTests, TestAddressSanitizer) { 49 TEST_F(AddressSanitizerTests, TestAddressSanitizer) {
50 // This test is only supposed to work when using AddressSanitizer. 50 // This test is only supposed to work when using AddressSanitizer.
51 // However, ASan/Win is not on the CQ yet, so compiler breakages may get into 51 // However, ASan/Win is not on the CQ yet, so compiler breakages may get into
52 // the code unnoticed. To avoid that, we compile this test in all Windows 52 // the code unnoticed. To avoid that, we compile this test in all Windows
53 // builds, but only run the AddressSanitizer-specific part of the test when 53 // builds, but only run the AddressSanitizer-specific part of the test when
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 << "The stack trace doesn't have a correct filename:\n" << data; 98 << "The stack trace doesn't have a correct filename:\n" << data;
99 } else { 99 } else {
100 LOG(WARNING) << "Pre-Vista versions are not supported."; 100 LOG(WARNING) << "Pre-Vista versions are not supported.";
101 } 101 }
102 } else { 102 } else {
103 LOG(WARNING) << "Not an AddressSanitizer build, skipping the run."; 103 LOG(WARNING) << "Not an AddressSanitizer build, skipping the run.";
104 } 104 }
105 } 105 }
106 106
107 } 107 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698