This is an archive of the discontinued LLVM Phabricator instance.

sanitizer_common: use 0 for empty stack id
ClosedPublic

Authored by dvyukov on Jul 11 2021, 5:49 AM.

Details

Summary

We use 0 for empty stack id from stack depot.
Deadlock detector 1 is the only place that uses -1
as a special case. Use 0 because there is a number
of checks of the form "if (stack id) ...".

Diff Detail

Event Timeline

dvyukov requested review of this revision.Jul 11 2021, 5:49 AM
dvyukov created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJul 11 2021, 5:49 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
melver accepted this revision.Jul 12 2021, 3:09 AM

How did this not result in errors before?

This revision is now accepted and ready to land.Jul 12 2021, 3:09 AM

How did this not result in errors before?

I don't know exactly, this code is not particularly maintained.
One option is that findEdge always assigns something to stk_from/stk_to so that the initial values are never used.
I found it when I experimented with introduction of strong typedefs for some types including stack IDs. It did not forgive such sloppiness as assigning random values to these types.

This revision was automatically updated to reflect the committed changes.