File tree 1 file changed +61
-0
lines changed
1 file changed +61
-0
lines changed Original file line number Diff line number Diff line change @@ -147,10 +147,71 @@ mod future_completes_during_trace {
147
147
async fn dump ( ) {
148
148
let handle = Handle :: current ( ) ;
149
149
let _dump = handle. dump ( ) . await ;
150
+ tokio:: task:: yield_now ( ) . await ;
150
151
}
151
152
152
153
rt. block_on ( async {
153
154
let _ = tokio:: join!( tokio:: spawn( complete_during_trace( ) ) , dump( ) ) ;
154
155
} ) ;
155
156
}
156
157
}
158
+
159
+ /// Regression tests for #6051.
160
+ ///
161
+ /// These tests ensure that tasks notified outside of a worker will not be
162
+ /// traced, since doing so will un-set their notified bit prior to them being
163
+ /// run and panic.
164
+ mod notified_during_tracing {
165
+ use super :: * ;
166
+
167
+ fn test ( rt : tokio:: runtime:: Runtime ) {
168
+ async fn dump ( ) {
169
+ loop {
170
+ let handle = Handle :: current ( ) ;
171
+ let _dump = handle. dump ( ) . await ;
172
+ // Without this yield, the `current_runtime` test hangs.
173
+ tokio:: task:: yield_now ( ) . await ;
174
+ }
175
+ }
176
+
177
+ rt. block_on ( async {
178
+ let timer = tokio:: spawn ( async {
179
+ loop {
180
+ tokio:: time:: sleep ( tokio:: time:: Duration :: from_nanos ( 1 ) ) . await ;
181
+ }
182
+ } ) ;
183
+
184
+ let timeout = async {
185
+ tokio:: time:: sleep ( tokio:: time:: Duration :: from_secs ( 1 ) ) . await ;
186
+ } ;
187
+
188
+ tokio:: select!(
189
+ biased;
190
+ _ = timeout => { } ,
191
+ _ = timer => { } ,
192
+ _ = dump( ) => { } ,
193
+ ) ;
194
+ } ) ;
195
+ }
196
+
197
+ #[ test]
198
+ fn current_thread ( ) {
199
+ let rt = runtime:: Builder :: new_current_thread ( )
200
+ . enable_all ( )
201
+ . build ( )
202
+ . unwrap ( ) ;
203
+
204
+ test ( rt)
205
+ }
206
+
207
+ #[ test]
208
+ fn multi_thread ( ) {
209
+ let rt = runtime:: Builder :: new_multi_thread ( )
210
+ . enable_all ( )
211
+ . worker_threads ( 3 )
212
+ . build ( )
213
+ . unwrap ( ) ;
214
+
215
+ test ( rt)
216
+ }
217
+ }
You can’t perform that action at this time.
0 commit comments