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

Side by Side Diff: Source/platform/heap/Heap.h

Issue 1259893002: Fix FreeList::zapFreedMemory to fail "use-of-uninitialized-value" on MSAN (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: PS4 without __msan_[un]poison Created 5 years, 4 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
« no previous file with comments | « no previous file | Source/platform/heap/Heap.cpp » ('j') | Source/wtf/AddressSanitizer.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // list in the next addToFreeList(). 71 // list in the next addToFreeList().
72 const uint8_t reuseAllowedZapValue = 0x2a; 72 const uint8_t reuseAllowedZapValue = 0x2a;
73 // A zap value used for freed memory that is forbidden to be added to the free 73 // A zap value used for freed memory that is forbidden to be added to the free
74 // list in the next addToFreeList(). 74 // list in the next addToFreeList().
75 const uint8_t reuseForbiddenZapValue = 0x2c; 75 const uint8_t reuseForbiddenZapValue = 0x2c;
76 76
77 // In non-production builds, memory is zapped when it's freed. The zapped 77 // In non-production builds, memory is zapped when it's freed. The zapped
78 // memory is zeroed out when the memory is reused in Heap::allocateObject(). 78 // memory is zeroed out when the memory is reused in Heap::allocateObject().
79 // In production builds, memory is not zapped (for performance). The memory 79 // In production builds, memory is not zapped (for performance). The memory
80 // is just zeroed out when it is added to the free list. 80 // is just zeroed out when it is added to the free list.
81 #if ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER) 81 #if defined(MEMORY_SANITIZER)
82 #define SET_MEMORY_INACCESSIBLE(address, size) \
83 FreeList::zapFreedMemory(address, size);
Alexander Potapenko 2015/07/29 13:39:42 Please add a TODO here indicating that we actually
kojii 2015/07/29 14:30:06 Done.
84 #define SET_MEMORY_ACCESSIBLE(address, size) \
85 memset((address), 0, (size))
86 #elif ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER)
82 #define SET_MEMORY_INACCESSIBLE(address, size) \ 87 #define SET_MEMORY_INACCESSIBLE(address, size) \
83 FreeList::zapFreedMemory(address, size); \ 88 FreeList::zapFreedMemory(address, size); \
84 ASAN_POISON_MEMORY_REGION(address, size) 89 ASAN_POISON_MEMORY_REGION(address, size)
85 #define SET_MEMORY_ACCESSIBLE(address, size) \ 90 #define SET_MEMORY_ACCESSIBLE(address, size) \
86 ASAN_UNPOISON_MEMORY_REGION(address, size); \ 91 ASAN_UNPOISON_MEMORY_REGION(address, size); \
87 memset((address), 0, (size)) 92 memset((address), 0, (size))
88 #else 93 #else
89 #define SET_MEMORY_INACCESSIBLE(address, size) memset((address), 0, (size)) 94 #define SET_MEMORY_INACCESSIBLE(address, size) memset((address), 0, (size))
90 #define SET_MEMORY_ACCESSIBLE(address, size) do { } while (false) 95 #define SET_MEMORY_ACCESSIBLE(address, size) do { } while (false)
91 #endif 96 #endif
(...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 size_t copySize = previousHeader->payloadSize(); 1393 size_t copySize = previousHeader->payloadSize();
1389 if (copySize > size) 1394 if (copySize > size)
1390 copySize = size; 1395 copySize = size;
1391 memcpy(address, previous, copySize); 1396 memcpy(address, previous, copySize);
1392 return address; 1397 return address;
1393 } 1398 }
1394 1399
1395 } // namespace blink 1400 } // namespace blink
1396 1401
1397 #endif // Heap_h 1402 #endif // Heap_h
OLDNEW
« no previous file with comments | « no previous file | Source/platform/heap/Heap.cpp » ('j') | Source/wtf/AddressSanitizer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698