Commit f4f4b27
Add Store.awaitSnapshotCapturable for race-free snapshot coordination (#19)
StoreStatus.InHostImport (and Paused/WaitingForFuel) is published from
inside a gated execution segment, before the executing continuation
parks and StoreExecutionGate releases its mutex. An embedder that
observes status.first { it == InHostImport } on another thread and then
calls captureSnapshotState intermittently hits the fail-fast
tryAcquireCapture and gets "store execution has not parked". This exact
race made SnapshotSuspensionSafetyJvmTest flaky.
Reordering the publication is not an option: the gate release is
implicit in the ContinuationInterceptor machinery and only happens once
the segment actually suspends. Instead, expose a public awaitable
primitive: awaitSnapshotCapturable() suspends until a capturable status
is published AND the gate has been released (by briefly taking the gate
mutex), so a follow-up captureSnapshotState cannot fail with "has not
parked" unless the guest resumes in between - which it cannot while the
parked host import is still blocked.
Also document the publish-before-park ordering on StoreStatus and
captureSnapshotState, switch the previously flaky test to the new
primitive, and add a focused stress test for capture of a parked host
import from another thread. Supersedes the test-level dispatcher drain
on branch fix/snapshot-suspension-safety-jvm-test.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent ddea5ee commit f4f4b27
2 files changed
Lines changed: 131 additions & 23 deletions
Lines changed: 57 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | 7 | | |
10 | 8 | | |
11 | 9 | | |
| |||
56 | 54 | | |
57 | 55 | | |
58 | 56 | | |
59 | | - | |
60 | 57 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
70 | 63 | | |
71 | 64 | | |
72 | 65 | | |
| |||
122 | 115 | | |
123 | 116 | | |
124 | 117 | | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
130 | 122 | | |
131 | 123 | | |
132 | 124 | | |
| |||
159 | 151 | | |
160 | 152 | | |
161 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
162 | 202 | | |
163 | 203 | | |
164 | 204 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
87 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
88 | 100 | | |
89 | 101 | | |
90 | 102 | | |
| |||
957 | 969 | | |
958 | 970 | | |
959 | 971 | | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
960 | 1012 | | |
961 | 1013 | | |
962 | 1014 | | |
| |||
973 | 1025 | | |
974 | 1026 | | |
975 | 1027 | | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
976 | 1034 | | |
977 | 1035 | | |
978 | 1036 | | |
| |||
986 | 1044 | | |
987 | 1045 | | |
988 | 1046 | | |
989 | | - | |
990 | | - | |
991 | | - | |
992 | | - | |
993 | | - | |
| 1047 | + | |
994 | 1048 | | |
995 | 1049 | | |
996 | 1050 | | |
| |||
1357 | 1411 | | |
1358 | 1412 | | |
1359 | 1413 | | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
1360 | 1419 | | |
1361 | 1420 | | |
1362 | 1421 | | |
| |||
1367 | 1426 | | |
1368 | 1427 | | |
1369 | 1428 | | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
1370 | 1438 | | |
1371 | 1439 | | |
1372 | 1440 | | |
| |||
0 commit comments