Commit 8ea3e10
Fix a case where a
This could happen with an orphaned `RCFI` managed by a `FutureManager`. `FutureManager` relies on `RCFI::IsSafeToDelete()` to know whether it can destroy an orphaned instance; however, `IsSafeToDelete()` only considers whether there are any pending futures in flight. Thus, if no future is pending, it would return true if invoked while the `RCFI` is running the user callback associated with a recently-completed future. Destroying the `RCFI` instance would clean up the future that is passed to the user callback, making it invalid and likely leading the user callback to crash when `Future::result()` suddenly becomes null.
To fix this, track whether a user callback is currently running using a dedicated flag protected by the common mutex.
PiperOrigin-RevId: 263039541ReferenceCountedFutureImpl could be deallocated while running a user callback.1 parent 1233fd9 commit 8ea3e10
File tree
2 files changed
+31
-12
lines changed- app/src
2 files changed
+31
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | | - | |
| 64 | + | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
77 | | - | |
| 76 | + | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
206 | | - | |
| 206 | + | |
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
273 | | - | |
274 | | - | |
| 273 | + | |
275 | 274 | | |
276 | 275 | | |
277 | 276 | | |
| |||
303 | 302 | | |
304 | 303 | | |
305 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
306 | 310 | | |
307 | 311 | | |
308 | 312 | | |
309 | 313 | | |
310 | 314 | | |
311 | 315 | | |
312 | | - | |
313 | | - | |
314 | | - | |
| 316 | + | |
315 | 317 | | |
316 | | - | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
317 | 325 | | |
318 | 326 | | |
319 | 327 | | |
| |||
494 | 502 | | |
495 | 503 | | |
496 | 504 | | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
497 | 510 | | |
498 | 511 | | |
499 | 512 | | |
| |||
544 | 557 | | |
545 | 558 | | |
546 | 559 | | |
547 | | - | |
| 560 | + | |
548 | 561 | | |
549 | 562 | | |
550 | 563 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
519 | 519 | | |
520 | 520 | | |
521 | 521 | | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
522 | 528 | | |
523 | 529 | | |
524 | 530 | | |
| |||
0 commit comments