Repository navigation
Conversation
Add the tests of vx-lang#4345 for the compiler fix in vx-lang#4356. In each pass of a loop, a task must get the value of its own pass, and the program must drop each channel end once. - Unit tests in src/hir/check/tasks.rs: the checker lists a moved variable and a copied Copy value as taken at the spawn. It does not list a variable that the task writes, or a reference. - An MLIR test: a moved struct with a Sender goes into the task by value, and a borrowed variable goes by address. - The values test gets a case where the task reads a field of a struct with a Sender, and then moves the whole struct. - The drop test gets three Sender cases: in a struct, two fields deep, and a field read before the move. - A deadlock report test: each pass moves both ends of its channel into a task. The report must show one wait on each channel. - A ThreadSanitizer test with Receivers and Senders moved in a loop. To check the tests, I broke the compiler. With the old lowering (no copy at the spawn), each new backend test failed, and ThreadSanitizer reported a data race. Each of four breaks of the checker failed its own unit test. Issue: vx-lang#4345 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In the values test, the case where a task reads a field and then moves the whole struct used a struct with a Sender. The compiler already adds a read of a field to such a task, for the deadlock report. So the case tested the same thing as struct_with_a_sender. Now the struct holds two numbers, and the read in the code is the only read before the move. On the old lowering, this case gets the values of a later pass. The drop test keeps one Sender case, sender_in_a_struct. The two other Sender cases failed in the same way as that case on the old lowering. The lines that said the channel closed passed on the old lowering too: one Sender was dropped twice and one never, and the two cancel out. Issue: vx-lang#4345 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue: #4345
This PR adds the tests of #4345 for the compiler fix in #4356. It changes only tests. The
GenMC clients, the formal models and the doc updates of #4345 come in later PRs.
The tests
The values test of #4356 already fails on the old compiler. So each test here must catch a
different way to break the code.
src/hir/check/tasks.rsCopyvalue as taken at thespawn. It does not list a variable that the task writes, or a reference. Before, onlya_cancel_or_a_time_limit_ends_sleep_and_tick.vxfound a break of the reference rule, by chance.a_task_gets_a_moved_sender_by_value_and_a_borrowed_variable_by_address.vxSendergoes into the task by value, and a borrowed variable goes by address. It does not depend on the order of the tasks.field_read_before_the_whole_valuesender_in_a_structSenderonce.a_deadlock_report_names_the_holder_of_each_channel_end_moved_into_a_task_in_a_loop.vxthread_sanitizer_finds_no_race_with_channel_ends_moved_into_tasks_in_a_loop.vxThe checks in the MLIR test are written by hand.
utils/update_mlir_test_checks.rswrites thewhole module (about 1,600 lines) and cannot run a RUN line that pipes into
vx-opt.How I checked that the tests can fail
lowerTaskignores the markers, and its check is offfield_read_before_the_whole_valueprintedpass 0 got 11.dropped 42printed twice.a_task_takes_a_variable_that_it_moves.Copyvaluesa_task_takes_a_copy_value_that_it_only_reads.a_task_does_not_take_a_variable_that_it_writes, and the MLIR test at the borrowed variable.a_task_does_not_take_a_reference_that_it_copies.On macOS arm64, all the RUN lines of the new and changed tests pass, and so do the 11
a_deadlock_report_*tests. I did not run the fullcargo test --workspace.For the reviewer
#4345 says that the checker does not mark a copied
Copycapture. #4356 marks it, andcopy_struct_read_by_fieldneeds that. The unit tests check what the code does.🤖 Generated with Claude Code