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

Side by Side Diff: base/threading/thread_local_storage_unittest.cc

Issue 2383833004: Ensure Freed TLS Slots Contain nullptr on Reallocation (Closed)
Patch Set: Add Banner Doc Created 4 years, 2 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #if defined(OS_WIN) 5 #if defined(OS_WIN)
6 #include <windows.h> 6 #include <windows.h>
7 #include <process.h> 7 #include <process.h>
8 #endif 8 #endif
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 delete threads[index]; 121 delete threads[index];
122 delete thread_delegates[index]; 122 delete thread_delegates[index];
123 123
124 // Verify that the destructor was called and that we reset. 124 // Verify that the destructor was called and that we reset.
125 EXPECT_EQ(values[index], kFinalTlsValue); 125 EXPECT_EQ(values[index], kFinalTlsValue);
126 } 126 }
127 tls_slot.Free(); // Stop doing callbacks to cleanup threads. 127 tls_slot.Free(); // Stop doing callbacks to cleanup threads.
128 } 128 }
129 129
130 TEST(ThreadLocalStorageTest, TLSReclaim) { 130 TEST(ThreadLocalStorageTest, TLSReclaim) {
131 // Creates and destroys many TLS slots. 131 // Creates and destroys many TLS slots and ensures they all zero-inited.
132 for (int i = 0; i < 1000; ++i) { 132 for (int i = 0; i < 1000; ++i) {
133 ThreadLocalStorage::Slot slot(nullptr); 133 ThreadLocalStorage::Slot slot(nullptr);
134 EXPECT_EQ(nullptr, slot.Get());
135 slot.Set(reinterpret_cast<void*>(0xBAADF00D));
136 EXPECT_EQ(reinterpret_cast<void*>(0xBAADF00D), slot.Get());
134 } 137 }
135 } 138 }
136 139
137 } // namespace base 140 } // namespace base
OLDNEW
« base/threading/thread_local_storage.cc ('K') | « base/threading/thread_local_storage.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698