This is an archive of the discontinued LLVM Phabricator instance.

[ASan] Report proper ASan error on allocator failures instead of CHECK(0)-ing
ClosedPublic

Authored by alekseyshl on Mar 12 2018, 4:56 PM.

Details

Reviewers
eugenis
Commits
rG0ee5a5577c38: [ASan] Disable new ASan error reporting tests on various ARMs.
rGb43b5580127c: [ASan] Disable aligned_alloc-alignment.cc on PPC64.
rG239533319f1a: [ASan] Disable aligned_alloc-alignment.cc on ppc64be
rG5062d7a22d94: [ASan] Disable aligned_alloc-alignment.cc test on gcc.
rGb276621d3d73: [ASan] Disable aligned_alloc-alignment.cc on Android.
rG506b8388ed87: [ASan] Add aligned_alloc declaration to aligned_alloc-alignment.cc test.
rG10f50a44c1fa: [ASan] Report proper ASan error on allocator failures instead of CHECK(0)-ing
rL328849: [ASan] Disable new ASan error reporting tests on various ARMs.
rCRT328849: [ASan] Disable new ASan error reporting tests on various ARMs.
rL328753: [ASan] Disable aligned_alloc-alignment.cc on PPC64.
rCRT328753: [ASan] Disable aligned_alloc-alignment.cc on PPC64.
rL328742: [ASan] Disable aligned_alloc-alignment.cc on ppc64be
rCRT328742: [ASan] Disable aligned_alloc-alignment.cc on ppc64be
rL328741: [ASan] Disable aligned_alloc-alignment.cc test on gcc.
rCRT328741: [ASan] Disable aligned_alloc-alignment.cc test on gcc.
rCRT328734: [ASan] Disable aligned_alloc-alignment.cc on Android.
rL328734: [ASan] Disable aligned_alloc-alignment.cc on Android.
rCRT328726: [ASan] Add aligned_alloc declaration to aligned_alloc-alignment.cc test.
rL328726: [ASan] Add aligned_alloc declaration to aligned_alloc-alignment.cc test.
rCRT328722: [ASan] Report proper ASan error on allocator failures instead of CHECK(0)-ing
rL328722: [ASan] Report proper ASan error on allocator failures instead of CHECK(0)-ing
Summary

Currently many allocator specific errors (OOM, for example) are reported as
a text message and CHECK(0) termination, not stack, no details, not too
helpful nor informative. To improve the situation, ASan detailed errors were
defined and reported under the appropriate conditions.

Issue: https://github.com/google/sanitizers/issues/887

Diff Detail

Repository
rL LLVM

Event Timeline

alekseyshl created this revision.Mar 12 2018, 4:56 PM
Herald added subscribers: Restricted Project, delcypher, kubamracek. · View Herald TranscriptMar 12 2018, 4:57 PM
eugenis added inline comments.Mar 16 2018, 3:30 PM
lib/asan/asan_allocator.cc
171 ↗(On Diff #138109)

This will not work with fast_unwind_on_fatal because there are no frame pointers. How hard is it to pass the stack down from the caller?

lib/asan/asan_errors.h
26 ↗(On Diff #138109)

Please update existing error objects with this constructor, too. Either before or after this patch.

  • Pass caller stack to quarantine callback to report on OOM.
alekseyshl marked an inline comment as done.Mar 20 2018, 12:08 PM
alekseyshl added inline comments.
lib/asan/asan_errors.h
26 ↗(On Diff #138109)

That was the plan, to update the rest in a separate patch, just did not want to add unrelated changes here.

  • Do not call SetAllocatorOutOfMemory in new interceptors

SetAllocatorOutOfMemory should not be called in new interceptors,
it should be called when OOM is actually detected and asan allocator
takes care of that.

eugenis accepted this revision.Mar 22 2018, 2:12 PM

Looks fine.

lib/asan/asan_allocator.cc
600 ↗(On Diff #139334)

Please double check that "stack" is not used after it is deallocated.

This revision is now accepted and ready to land.Mar 22 2018, 2:12 PM
alekseyshl marked an inline comment as done.Mar 22 2018, 2:22 PM
alekseyshl added inline comments.
lib/asan/asan_allocator.cc
600 ↗(On Diff #139334)

Yep, QuarantineCallback instance is not stored anywhere, it is used in the context of Put() call only.

alekseyshl marked an inline comment as done.
  • Pass caller stack to quarantine callback to report on OOM.
  • SetAllocatorOutOfMemory should not be called in new interceptors,
  • Disable LSan allocator test in LSan standalone mode.
This revision was automatically updated to reflect the committed changes.