mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[SwiftCore]: Don't always clobber memory
The new build system set `SWIFT_RUNTIME_CLOBBER_FREED_OBJECTS` to 0.
Unfortunately, the check in the Swift runtime used `#ifdef`, so even
though it was turned off, it was actually enabled in some cases.
Fixing the issue in the build system as well as switching the check to
verify that value of `SWIFT_RUNTIME_CLOBBER_FREED_OBJECTS` is taken into
account in the sources. C/C++ implicitly defines macro values to 1 when
set without a value and 0 when it is not set.
Also making the hex a bit more recognizable and grep'able by including
it as a comment.
Fixes: rdar://149210738
(cherry picked from commit 6f39a52afc)
This commit is contained in:
@@ -875,7 +875,7 @@ void swift::swift_deallocPartialClassInstance(HeapObject *object,
|
||||
swift_deallocClassInstance(object, allocatedSize, allocatedAlignMask);
|
||||
}
|
||||
|
||||
#if !defined(__APPLE__) && defined(SWIFT_RUNTIME_CLOBBER_FREED_OBJECTS)
|
||||
#if !defined(__APPLE__) && SWIFT_RUNTIME_CLOBBER_FREED_OBJECTS
|
||||
static inline void memset_pattern8(void *b, const void *pattern8, size_t len) {
|
||||
char *ptr = static_cast<char *>(b);
|
||||
while (len >= 8) {
|
||||
@@ -898,9 +898,9 @@ static inline void swift_deallocObjectImpl(HeapObject *object,
|
||||
}
|
||||
assert(object->refCounts.isDeiniting());
|
||||
SWIFT_RT_TRACK_INVOCATION(object, swift_deallocObject);
|
||||
#ifdef SWIFT_RUNTIME_CLOBBER_FREED_OBJECTS
|
||||
#if SWIFT_RUNTIME_CLOBBER_FREED_OBJECTS
|
||||
memset_pattern8((uint8_t *)object + sizeof(HeapObject),
|
||||
"\xAB\xAD\x1D\xEA\xF4\xEE\xD0\bB9",
|
||||
"\xF0\xEF\xBE\xAD\xDE\xED\xFE\x0F", // 0x0ffeeddeadbeeff0
|
||||
allocatedSize - sizeof(HeapObject));
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user