Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Narrow the CRC scope in file_test #5043

Merged
merged 4 commits into from
Feb 28, 2025

Conversation

jonmeow
Copy link
Contributor

@jonmeow jonmeow commented Feb 28, 2025

This narrows the scope of the CRC to try to get better behavior around mutex lock releasing on crash. Closes #5042.

This breaks apart ProcessTestFileAndRun because we need to process the test file for SET-CAPTURE-CONSOLE-OUTPUT. The test file processing should more reliably not crash than the core Run logic though, so should be reasonably safe to put outside the CRC.

Also support --threads=1 for disabling threading. This is the flipside for me of reducing how much is in the CRC: make it easier to run on a single thread if the CRC gets in the way of debugging. This also means a typical copy-paste execution of a single test will be single-threaded.

@github-actions github-actions bot added explorer Action items related to Carbon explorer code toolchain labels Feb 28, 2025
@jonmeow jonmeow force-pushed the file-test-crc branch 3 times, most recently from 48e598c to 7a33be3 Compare February 28, 2025 18:21
Copy link
Contributor

@danakj danakj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

}
});
if (thread_crashed) {
// Guard access to both `llvm::errs` and `crashed`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering while reading if GUARDED_BY and REQUIRES would be useful here. I've not actually written code with them before though.

https://clang.llvm.org/docs/ThreadSafetyAnalysis.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't own the things we're trying to lock, many different systems touch output, so it's an awkward fit for what we're trying to lock here. We'd basically need to add helpers around things like llvm::errs(), and even then we should expect incomplete coverage because there are uses that are too indirect to capture.

That said, we also don't enable -fsanitize=thread so I think annotations would probably be brittle. If you think this would be worthwhile to change, it seems out of the scope of this PR, so perhaps discuss it on #infra?

jonmeow and others added 2 commits February 28, 2025 11:56
Co-authored-by: Geoff Romer <gromer@google.com>
@geoffromer geoffromer added this pull request to the merge queue Feb 28, 2025
Merged via the queue into carbon-language:trunk with commit 6d6987d Feb 28, 2025
8 checks passed
@jonmeow jonmeow deleted the file-test-crc branch February 28, 2025 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
explorer Action items related to Carbon explorer code toolchain
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CARBON_CHECK() causes test timeout in a language server test
3 participants