This is an archive of the discontinued LLVM Phabricator instance.

[tsan] Add debugging API to retrieve the "external tag" from reports
ClosedPublic

Authored by kubamracek on May 9 2018, 1:15 PM.

Diff Detail

Event Timeline

kubamracek created this revision.May 9 2018, 1:15 PM
Herald added a subscriber: Restricted Project. · View Herald TranscriptMay 9 2018, 1:15 PM
delcypher added inline comments.May 9 2018, 2:25 PM
lib/tsan/rtl/tsan_debugging.cc
89

Why return 1? What does that mean?

lib/tsan/rtl/tsan_interface.h
122

There's no documentation on the meaning of the arguments or the return value here.

test/tsan/Darwin/external-swift-debugging.cc
11

I know for ASan we ship the interface header with Clang. Do we not do that with TSan? If we do can you just include that so you don't have to redefine this here?

40

I don't understand this. There's no Swift code in this test case so how is this a Swift access race?

kubamracek added inline comments.May 9 2018, 2:35 PM
lib/tsan/rtl/tsan_debugging.cc
89

All the APIs return 1 on success, 0 on failure.

lib/tsan/rtl/tsan_interface.h
122

See comments around. "report" is an opaque pointer representing the report we want to extract data from, "tag" is the output variable. All these APIs return non-zero on success, zero on failure.

Sorry about the lack of formal documentation here, it's because this is only for debugger integration (and not really a public API) and this header file isn't shipped anywhere.

test/tsan/Darwin/external-swift-debugging.cc
11

Yeah, we do not. The reason is that these are not really stable APIs.

40

The test is faking what a Swift code would do via the __tsan_external_write call.

LGTM, but would be better with a comment in the header describing the function

lib/tsan/rtl/tsan_interface.h
122

I would also prefer a basic doxygen comment.

This revision is now accepted and ready to land.May 10 2018, 11:20 AM

Added a doxy-style comment describing the function.

@delcypher @george.karpenkov added a comment. looks good now?

delcypher added inline comments.May 10 2018, 2:11 PM
test/tsan/Darwin/external-swift-debugging.cc
19

Why does tag need to be a global here? Can't it just be a literal in ExternalWrite which is the only place its used.

40

This is still incredibly unclear. Why when using __tsan_external_write

  • Is it okay to pass nullptr as caller_pc?
  • The fact that 0x1 means a swift race is not all obvious. A bit of grepping shows this is defined in lib/tsan/rtl/tsan_defs.h but this is not at all obvious.

Please add some comments to ExternalWrite to explain what is going on (i.e. that you're faking a swift access will a special tag that is defined in lib/tsan/rtl/tsan_defs.h ).

63

This variable is hiding the tag global variable of the same name. Removing the global variable will fix this.

kubamracek added inline comments.May 10 2018, 2:15 PM
test/tsan/Darwin/external-swift-debugging.cc
40

I don't want to expand the scope of this patch. Let's strictly focus on the added API.

test/tsan/Darwin/external-swift-debugging.cc
40

@delcypher this file is just a test. The race itself is immaterial here, from my understanding the test is there to check that we can get the correct tag from the report. In fact, all the CHECK: lines about the race could be even dropped.

Updated the test file to avoid name clash on "tag".

delcypher added inline comments.May 10 2018, 2:33 PM
test/tsan/Darwin/external-swift-debugging.cc
21

@kubamracek Great. Thanks for using a clearer name. A comment probably isn't necessary anymore. Out of curiosity, why does this variable have static storage? I can't think of a reason why that would be necessary.

40

@george.karpenkov Although this file is a test, it's important to make the test as understandable as possible without putting too much burden on the test writer. This test in the original patch wasn't very easy to understand and a simple comment explaining what ExternalWrite was doing would help with understanding.

That being said now that @kubamracek has moved the tag definition into ExternalWrite and named it kSwiftAccessRaceTag to code is clearer and a comment probably isn't needed any more.

Dropping 'static'.

@delcypher @george.karpenkov added a comment. looks good now?

Yep. Much better.

delcypher accepted this revision.May 10 2018, 2:38 PM

Thanks for making changes. LGTM.

This revision was automatically updated to reflect the committed changes.