To make the TSan external API work with Swift and other use cases, we need to track "tags" for individual memory accesses. Since there is no space to store this information in shadow cells, let's use the thread traces for that. This patch stores the tag as an extra frame in the stack traces (by calling FuncEntry and FuncExit with the address of a registered tag), this extra frame is then stripped before printing the backtrace to stderr.
Details
Diff Detail
Event Timeline
lib/tsan/rtl/tsan_rtl_report.cc | ||
---|---|---|
662 | I think it's better to separate stack and tag directly in ObtainCurrentStack and RestoreStack because:
| |
665 | I wonder if we need ReportTypeExternalRace at all. |
One last thing. Otherwise LGTM.
lib/tsan/rtl/tsan_rtl_report.cc | ||
---|---|---|
662 | Calculate typ before creating ScopedReport and remove SetType function. It feels clumsy that we can't figure out report type when we are creating it and add setters to patch it afterwards. if (tags[0] != kExternalTagNone || tags[1] != kExternalTagNone) typ = ReportTypeExternalRace; ScopedReport rep(typ); will do. |
I think it's better to separate stack and tag directly in ObtainCurrentStack and RestoreStack because: