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

Side by Side Diff: syzygy/agent/asan/block.cc

Issue 2527533003: Make SyzyAsan support the allocation > 1GB (Closed)
Patch Set: Do an unguarded alloc if the size > 2GB Created 4 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
OLDNEW
1 // Copyright 2014 Google Inc. All Rights Reserved. 1 // Copyright 2014 Google Inc. All Rights Reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 uint32_t size, 232 uint32_t size,
233 uint32_t min_left_redzone_size, 233 uint32_t min_left_redzone_size,
234 uint32_t min_right_redzone_size, 234 uint32_t min_right_redzone_size,
235 BlockLayout* layout) { 235 BlockLayout* layout) {
236 DCHECK_LE(kShadowRatio, chunk_size); 236 DCHECK_LE(kShadowRatio, chunk_size);
237 DCHECK(::common::IsPowerOfTwo(chunk_size)); 237 DCHECK(::common::IsPowerOfTwo(chunk_size));
238 DCHECK_LE(kShadowRatio, alignment); 238 DCHECK_LE(kShadowRatio, alignment);
239 DCHECK_GE(chunk_size, alignment); 239 DCHECK_GE(chunk_size, alignment);
240 DCHECK(::common::IsPowerOfTwo(alignment)); 240 DCHECK(::common::IsPowerOfTwo(alignment));
241 241
242 // Prevent from trying to allocate a memory block bigger than what we can
243 // represent in the block header.
244 if (size > kMaxBlockHeaderBodySize)
245 return false;
246
242 // Calculate minimum redzone sizes that respect the parameters. 247 // Calculate minimum redzone sizes that respect the parameters.
243 uint32_t left_redzone_size = static_cast<uint32_t>(::common::AlignUp( 248 uint32_t left_redzone_size = static_cast<uint32_t>(::common::AlignUp(
244 std::max<uint32_t>(min_left_redzone_size, sizeof(BlockHeader)), 249 std::max<uint32_t>(min_left_redzone_size, sizeof(BlockHeader)),
245 alignment)); 250 alignment));
246 uint32_t right_redzone_size = std::max<uint32_t>(min_right_redzone_size, 251 uint32_t right_redzone_size = std::max<uint32_t>(min_right_redzone_size,
247 sizeof(BlockTrailer)); 252 sizeof(BlockTrailer));
248 253
249 // Calculate the total size of the allocation. 254 // Calculate the total size of the allocation.
250 uint32_t total_size = static_cast<uint32_t>(::common::AlignUp( 255 uint32_t total_size = static_cast<uint32_t>(::common::AlignUp(
251 left_redzone_size + size + right_redzone_size, chunk_size)); 256 left_redzone_size + size + right_redzone_size, chunk_size));
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 void SetOnExceptionCallback(OnExceptionCallback callback) { 938 void SetOnExceptionCallback(OnExceptionCallback callback) {
934 g_on_exception_callback = callback; 939 g_on_exception_callback = callback;
935 } 940 }
936 941
937 void ClearOnExceptionCallback() { 942 void ClearOnExceptionCallback() {
938 g_on_exception_callback.Reset(); 943 g_on_exception_callback.Reset();
939 } 944 }
940 945
941 } // namespace asan 946 } // namespace asan
942 } // namespace agent 947 } // namespace agent
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698