This is an archive of the discontinued LLVM Phabricator instance.

[Support] Fix Windows dump file hang with multi-threaded crashes
ClosedPublic

Authored by andrewng on Jul 1 2022, 9:53 AM.

Details

Summary

Prevents deadlock between MiniDumpWriteDump and
CryptAcquireContextW (called via fs::createTemporaryFile) in
WriteWindowsDumpFile.

However, there's no guarantee that deadlock can't still occur between
MiniDumpWriteDump and some other Win32 API call. But that would appear
to be the "accepted" risk of using MiniDumpWriteDump in this manner.

Diff Detail

Event Timeline

andrewng created this revision.Jul 1 2022, 9:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 1 2022, 9:53 AM
andrewng requested review of this revision.Jul 1 2022, 9:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 1 2022, 9:53 AM
rnk added a comment.Jul 6 2022, 4:12 PM

The change seems reasonable, but I hesitate to add the test as is.

llvm/unittests/Support/WindowsDumpFileTest.cpp
41 ↗(On Diff #441722)

I appreciate the effort and thoroughness that went into writing this test, but I don't think we should commit it as is.

If the critical section is removed, this test will nondeterministically fail with a timeout due to the deadlock. That's not something we can use to bisect problems or debug why things went wrong. I don't think it's worth spending resources to run this test if it can't produce actionable results from a buildbot.

andrewng added inline comments.Jul 7 2022, 9:23 AM
llvm/unittests/Support/WindowsDumpFileTest.cpp
41 ↗(On Diff #441722)

I'm not sure that there's a "better" way to test this issue. Do you have any suggestions? Or are you suggesting to just discard the testing completely? Which I think could be acceptable in this case. I added testing because that's usually a requirement for any change to be accepted.

rnk added inline comments.Jul 7 2022, 9:56 AM
llvm/unittests/Support/WindowsDumpFileTest.cpp
41 ↗(On Diff #441722)

Yes, I think it's fine to land this code change without a test. It doesn't seem practical in this case.

andrewng updated this revision to Diff 442992.Jul 7 2022, 10:51 AM

Address review comment and removed the unit test.

rnk accepted this revision.Jul 7 2022, 11:12 AM

lgtm, thanks!

This revision is now accepted and ready to land.Jul 7 2022, 11:12 AM
This revision was landed with ongoing or failed builds.Jul 8 2022, 2:32 AM
This revision was automatically updated to reflect the committed changes.