This is an archive of the discontinued LLVM Phabricator instance.

Introduce `sanitizer_malloc_introspect_t` for Darwin which is a sub-class of Darwin's `malloc_introspection_t` and use it when setting up the malloc zone.
ClosedPublic

Authored by delcypher on Nov 2 2018, 12:23 PM.

Details

Summary

Currently sanitizer_malloc_introspection_t just adds a version field
which is used to version the allocator ABI. The current allocator ABI
version is returned by the new GetMallocZoneAllocatorEnumerationVersion() function.

The motivation behind this change is to allow external processes to
determine the allocator ABI of a sanitized process.

rdar://problem/45284065

Diff Detail

Repository
rL LLVM

Event Timeline

delcypher created this revision.Nov 2 2018, 12:23 PM
Herald added a subscriber: Restricted Project. · View Herald TranscriptNov 2 2018, 12:23 PM

Looks good. I assume the struct definition cannot be moved into the .inc file because we're going to need to access it from other places?

@kubamracek

Looks good. I assume the struct definition cannot be moved into the .inc file because we're going to need to access it from other places?

You raise a good point. Right now (in my fork of compiler-rt) the header file exists because in my fork ASan actually subclasses sanitizer_malloc_introspection_t so that it can add its own fields. Due to the way this is implemented it means`sanitizer_malloc_introspection_t` needs to be in its own header file. However, ASan's sub class of sanitizer_malloc_introspection_t actually only contains two non-ASan specific fields (pointer to allocator and the size of the allocator). This means we could move those fields into sanitizer_malloc_introspection_t and remove the ASan specific sub class of sanitizer_malloc_introspection_t. If we do this we can move sanitizer_malloc_introspection_t into sanitizer_common/sanitizer_malloc_mac.inc. However we still need each sanitizer to initialise these fields because they could be different for each sanitizer. Right now initialising these fields is only important for ASan so for other sanitizers we could just leave these set to zero until we actually need to do something different.

What do you think?

Okay, let's initially remove the header file and just move the struct into the .inc file. We can always move it to a separate header later if needed.

delcypher updated this revision to Diff 173156.Nov 8 2018, 6:32 AM

Move sanitizer_malloc_introspect_t out of a header file into the only source
file where it is actually used.

@kubamracek

Okay, let's initially remove the header file and just move the struct into the .inc file. We can always move it to a separate header later if needed.

Done. Good to go now?

kubamracek accepted this revision.Nov 8 2018, 6:49 AM
This revision is now accepted and ready to land.Nov 8 2018, 6:49 AM
This revision was automatically updated to reflect the committed changes.