This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Don't run malloc hooks for stacktraces
Changes PlannedPublic

Authored by vitalybuka on Apr 11 2022, 8:45 PM.

Details

Summary

Usually when we generated stacktraces the process is in error state, so
running hooks may crash the process and prevent meaningfull error report.

Symbolizer, unwinder and pthread are potential source of mallocs.

https://b.corp.google.com/issues/228110771

Diff Detail

Event Timeline

vitalybuka created this revision.Apr 11 2022, 8:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2022, 8:45 PM
vitalybuka requested review of this revision.Apr 11 2022, 8:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2022, 8:45 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
vitalybuka edited the summary of this revision. (Show Details)Apr 12 2022, 12:30 PM
vitalybuka edited the summary of this revision. (Show Details)
kda accepted this revision.Apr 12 2022, 4:36 PM
kda added inline comments.
compiler-rt/test/msan/Linux/malloc_hooks.cpp
25 ↗(On Diff #422111)

While this shows that the hooks are not called, I'm not sure that it demonstrates that they would usually be called. Perhaps call a non-symbolizer method and show them increasing?

This revision is now accepted and ready to land.Apr 12 2022, 4:36 PM
kstoimenov added inline comments.Apr 12 2022, 4:41 PM
compiler-rt/test/msan/Linux/malloc_hooks.cpp
8 ↗(On Diff #422111)

Make this static?

21 ↗(On Diff #422111)

Should we allocate memory to make sure that 'hooks' is non-zero? Also maybe add assert to check that is it is > 0.?

extend on other sanitizers

vitalybuka retitled this revision from [sanitizer] Don't run malloc hooks for symbolizer to [sanitizer] Don't run malloc hooks for stacktraces.Apr 13 2022, 12:37 AM
vitalybuka edited the summary of this revision. (Show Details)
vitalybuka marked 3 inline comments as done.Apr 13 2022, 9:24 AM
vitalybuka added inline comments.
compiler-rt/test/msan/Linux/malloc_hooks.cpp
21 ↗(On Diff #422111)

No, we have multiple tests which check that callbacks works..

25 ↗(On Diff #422111)

No, we have multiple tests which check that callbacks works..
E.g. llvm-project/compiler-rt/test/sanitizer_common/TestCases/malloc_hook.cpp

kstoimenov accepted this revision.Apr 13 2022, 11:09 AM
kstoimenov added inline comments.
compiler-rt/lib/sanitizer_common/sanitizer_common.cpp
313

Maybe this can be a static class member of ScopedDisableMallocHooks? You could add a static ScopedDisableMallocHooks::DisableMallocHooks accessor. Your call.

vitalybuka marked 3 inline comments as done.Apr 13 2022, 11:11 AM
vitalybuka added inline comments.
compiler-rt/lib/sanitizer_common/sanitizer_common.cpp
313

It makes it visible for linker

This revision was landed with ongoing or failed builds.Apr 13 2022, 11:45 AM
This revision was automatically updated to reflect the committed changes.
vitalybuka marked an inline comment as done.
vitalybuka reopened this revision.Apr 13 2022, 1:11 PM

Reverting

This revision is now accepted and ready to land.Apr 13 2022, 1:11 PM
This revision was automatically updated to reflect the committed changes.
vitalybuka reopened this revision.Apr 13 2022, 11:52 PM
This revision is now accepted and ready to land.Apr 13 2022, 11:52 PM
vitalybuka planned changes to this revision.Apr 14 2022, 11:00 AM

I probably going to abandon this, as I don't see good solution for all platforms.
Seems having sanitizer-unclean hooks is not good idea anyway.