Commit fece6ff
authored
Fix a race condition in Promise (#7602)
Promise needs to update `m_shared_state` before fulfilling the promise, as
`Future::get()` on another thread could return before the write occurs. If the
Promise is destroyed immediately after `get()` returns, the destructor could
then read the non-null value of `m_shared_state` before the write happens and
attempt to report a broken promise error, which hits an assertion.1 parent 589dbbe commit fece6ff
File tree
3 files changed
+24
-10
lines changed- src/realm/util
- test
3 files changed
+24
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
495 | | - | |
496 | | - | |
| 495 | + | |
| 496 | + | |
497 | 497 | | |
498 | 498 | | |
499 | 499 | | |
500 | 500 | | |
501 | 501 | | |
502 | 502 | | |
503 | | - | |
504 | | - | |
| 503 | + | |
| 504 | + | |
505 | 505 | | |
506 | 506 | | |
507 | 507 | | |
508 | 508 | | |
509 | 509 | | |
510 | 510 | | |
511 | | - | |
512 | | - | |
| 511 | + | |
| 512 | + | |
513 | 513 | | |
514 | 514 | | |
515 | 515 | | |
| |||
547 | 547 | | |
548 | 548 | | |
549 | 549 | | |
550 | | - | |
551 | | - | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
552 | 554 | | |
553 | 555 | | |
554 | 556 | | |
| |||
1270 | 1272 | | |
1271 | 1273 | | |
1272 | 1274 | | |
1273 | | - | |
1274 | | - | |
| 1275 | + | |
| 1276 | + | |
1275 | 1277 | | |
1276 | 1278 | | |
1277 | 1279 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2235 | 2235 | | |
2236 | 2236 | | |
2237 | 2237 | | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
2238 | 2249 | | |
2239 | 2250 | | |
2240 | 2251 | | |
| |||
0 commit comments