This is an archive of the discontinued LLVM Phabricator instance.

[hwasan] Add non-exception variant of operator delete[] for hwasan
ClosedPublic

Authored by leonardchan on Mar 6 2023, 6:35 PM.

Diff Detail

Event Timeline

leonardchan created this revision.Mar 6 2023, 6:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 6 2023, 6:35 PM
Herald added a subscriber: Enna1. · View Herald Transcript
leonardchan requested review of this revision.Mar 6 2023, 6:35 PM
Herald added a subscriber: Restricted Project. · View Herald TranscriptMar 6 2023, 6:35 PM

Hmm, so test in compiler-rt/test/hwasan/TestCases/new-test.cpp does exercise this function via operator delete[](alloc, size, align);, but since we provide weak definitions for these symbols, even if the hwasan implementation isn't provided, then it'll default to the one provided by stdlib_new_delete.cpp.o in libc++. Not sure how easy it would be to tell the testing infrastructure not to use some specific symbols from libc++.

vitalybuka accepted this revision.Mar 6 2023, 7:35 PM
This revision is now accepted and ready to land.Mar 6 2023, 7:35 PM
This revision was landed with ongoing or failed builds.Mar 6 2023, 7:46 PM
This revision was automatically updated to reflect the committed changes.

Hmm, so test in compiler-rt/test/hwasan/TestCases/new-test.cpp does exercise this function via operator delete[](alloc, size, align);, but since we provide weak definitions for these symbols, even if the hwasan implementation isn't provided, then it'll default to the one provided by stdlib_new_delete.cpp.o in libc++. Not sure how easy it would be to tell the testing infrastructure not to use some specific symbols from libc++.

If hwasan had the same new vs malloc and new flavor matching stuff in its allocator that asan et al have, then the test could do each operator new signature and then call the internal form of the free function telling it to check that it came from the expected source. If it's instead the libc++ new that just calls malloc, you'll get a mismatch. And likewise you can use the internal allocation path with signature marker explicitly in the test, and then test against the operator delete signature.