This is an archive of the discontinued LLVM Phabricator instance.

[cmake][Fuchsia] Add -ftrivial-auto-var-init=zero to runtimes build
Needs ReviewPublic

Authored by leonardchan on Oct 11 2022, 1:59 PM.

Details

Reviewers
phosek
mcgrathr
Summary

This might allow lsan to find more leaks that would have gone undetected. When lsan searches for leaked pointers on the stack, if a leaked pointer that was pushed to the stack in a prior function call would not be scrubbed on a future function call, then the memory snapshot will see the pointer on the stack and not mark it as leaked. Such holes can exist in the lsan runtime where there may be uninitialized data. Adding auto-var-init can scrub some of that data and might be able to catch more leaks that would've gone undetected this way.

See https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=111351 for more details.

Diff Detail

Event Timeline

leonardchan created this revision.Oct 11 2022, 1:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 11 2022, 1:59 PM
Herald added a subscriber: abrachet. · View Herald Transcript
leonardchan requested review of this revision.Oct 11 2022, 1:59 PM

I had imagined making lsan always do this since there's a specific lsan-related rationale for it that applies to everybody.
I'm not clear on how cmake structures things and whether sanitizer_common would have to do it unconditionally since it's used by lsan code.

Doing this generally seems fine to me, but in the general case it's considered a bug-masking feature (with =zero) and we should contemplate how much we want to expect that compiler-rt might have bugs that we will be making it harder for us to notice and properly fix.

I had imagined making lsan always do this since there's a specific lsan-related rationale for it that applies to everybody.
I'm not clear on how cmake structures things and whether sanitizer_common would have to do it unconditionally since it's used by lsan code.

Doing this generally seems fine to me, but in the general case it's considered a bug-masking feature (with =zero) and we should contemplate how much we want to expect that compiler-rt might have bugs that we will be making it harder for us to notice and properly fix.

Oh I see. Yeah I had just been thinking of turning it on for us rather than for all of lsan for everyone. Is something like https://reviews.llvm.org/D135716 what you were thinking?

It may help with some cases, but still does not guarantee that pointer will not survive in paddings or red-zones.

any chance of using pattern init rather than zero init, so this doesn't hide uninitialized bugs?