Commit 9e79395
committed
Auto merge of #151509 - Zoxc:gen-color-race, r=zetanumbers,petrochenkov
Handle race when coloring nodes concurrently as both green and red
This fixes a race where a duplicate dep node gets written to the dep graph if a node was marked as green and promoted during execution, then marked as red after execution.
This can occur when a `no_hash` query A depends on a query B which cannot be forced so it was not colored when starting execution of query A. During the execution of query A it will execute query B and color it green. Before A finishes another thread tries to mark A green, this time succeeding as B is now green, and A gets promoted and written to metadata. Execution of A then finishes and because it's `no_hash` we assume the result changed and thus we color the node again, now as red and write it to metadata again. This doesn't happen with non-`no_hash` queries as they will be green if all their dependencies are green.
This changes the code coloring nodes red to also use `compare_exchange` to deal with this race ensuring that the coloring of nodes only happens once.
Fixes #150018
Fixes #142778
Fixes #141540File tree
2 files changed
+37
-32
lines changed- compiler/rustc_query_system/src/dep_graph
2 files changed
+37
-32
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
788 | 788 | | |
789 | 789 | | |
790 | 790 | | |
791 | | - | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
792 | 795 | | |
793 | 796 | | |
794 | 797 | | |
795 | 798 | | |
796 | 799 | | |
797 | | - | |
798 | | - | |
799 | | - | |
800 | | - | |
801 | | - | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
802 | 807 | | |
803 | 808 | | |
804 | 809 | | |
| |||
1018 | 1023 | | |
1019 | 1024 | | |
1020 | 1025 | | |
1021 | | - | |
1022 | | - | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
1023 | 1030 | | |
1024 | 1031 | | |
1025 | 1032 | | |
| |||
1390 | 1397 | | |
1391 | 1398 | | |
1392 | 1399 | | |
1393 | | - | |
1394 | | - | |
1395 | | - | |
1396 | | - | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
1397 | 1407 | | |
1398 | 1408 | | |
1399 | 1409 | | |
1400 | | - | |
| 1410 | + | |
| 1411 | + | |
1401 | 1412 | | |
1402 | 1413 | | |
1403 | 1414 | | |
1404 | | - | |
| 1415 | + | |
1405 | 1416 | | |
1406 | 1417 | | |
1407 | 1418 | | |
1408 | 1419 | | |
1409 | | - | |
1410 | | - | |
1411 | | - | |
1412 | | - | |
| 1420 | + | |
1413 | 1421 | | |
1414 | 1422 | | |
1415 | 1423 | | |
| |||
1432 | 1440 | | |
1433 | 1441 | | |
1434 | 1442 | | |
1435 | | - | |
| 1443 | + | |
1436 | 1444 | | |
1437 | 1445 | | |
1438 | 1446 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
898 | 898 | | |
899 | 899 | | |
900 | 900 | | |
901 | | - | |
902 | | - | |
903 | | - | |
904 | | - | |
905 | | - | |
906 | | - | |
907 | | - | |
908 | | - | |
909 | | - | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
910 | 907 | | |
911 | 908 | | |
912 | 909 | | |
| |||
918 | 915 | | |
919 | 916 | | |
920 | 917 | | |
921 | | - | |
| 918 | + | |
922 | 919 | | |
923 | 920 | | |
924 | 921 | | |
925 | 922 | | |
926 | 923 | | |
927 | | - | |
| 924 | + | |
928 | 925 | | |
929 | 926 | | |
930 | 927 | | |
931 | 928 | | |
932 | 929 | | |
933 | 930 | | |
934 | 931 | | |
935 | | - | |
| 932 | + | |
936 | 933 | | |
937 | 934 | | |
938 | 935 | | |
| |||
942 | 939 | | |
943 | 940 | | |
944 | 941 | | |
945 | | - | |
| 942 | + | |
946 | 943 | | |
947 | 944 | | |
948 | 945 | | |
| |||
0 commit comments