Commit 69bb1c6
authored
Objects may be temporarily "resurrected" in destructors when calling
finalizers or watcher callbacks. We previously undid the resurrection
by decrementing the reference count using `Py_SET_REFCNT`. This was not
thread-safe because other threads might be accessing the object
(modifying its reference count) if it was exposed by the finalizer,
watcher callback, or temporarily accessed by a racy dictionary or list
access.
This adds internal-only thread-safe functions for temporary object
resurrection during destructors.
(cherry picked from commit f4f5308)
1 parent 304111e commit 69bb1c6
File tree
6 files changed
+87
-20
lines changed- Include/internal
- Misc/NEWS.d/next/Core and Builtins
- Objects
6 files changed
+87
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
572 | 572 | | |
573 | 573 | | |
574 | 574 | | |
| 575 | + | |
575 | 576 | | |
576 | 577 | | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
577 | 621 | | |
578 | 622 | | |
579 | 623 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1845 | 1845 | | |
1846 | 1846 | | |
1847 | 1847 | | |
1848 | | - | |
1849 | | - | |
| 1848 | + | |
1850 | 1849 | | |
1851 | | - | |
1852 | | - | |
| 1850 | + | |
1853 | 1851 | | |
1854 | 1852 | | |
1855 | | - | |
1856 | 1853 | | |
1857 | 1854 | | |
1858 | 1855 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3150 | 3150 | | |
3151 | 3151 | | |
3152 | 3152 | | |
3153 | | - | |
3154 | | - | |
| 3153 | + | |
3155 | 3154 | | |
3156 | | - | |
3157 | | - | |
| 3155 | + | |
3158 | 3156 | | |
3159 | 3157 | | |
3160 | | - | |
3161 | 3158 | | |
3162 | 3159 | | |
3163 | 3160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
986 | 986 | | |
987 | 987 | | |
988 | 988 | | |
989 | | - | |
990 | | - | |
| 989 | + | |
991 | 990 | | |
992 | | - | |
993 | | - | |
| 991 | + | |
994 | 992 | | |
995 | 993 | | |
996 | | - | |
997 | 994 | | |
998 | 995 | | |
999 | 996 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
363 | | - | |
364 | | - | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
365 | 367 | | |
366 | 368 | | |
367 | 369 | | |
| |||
402 | 404 | | |
403 | 405 | | |
404 | 406 | | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
405 | 416 | | |
406 | 417 | | |
407 | 418 | | |
| |||
470 | 481 | | |
471 | 482 | | |
472 | 483 | | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
473 | 504 | | |
474 | 505 | | |
475 | 506 | | |
| |||
548 | 579 | | |
549 | 580 | | |
550 | 581 | | |
551 | | - | |
| 582 | + | |
552 | 583 | | |
553 | 584 | | |
554 | 585 | | |
| |||
558 | 589 | | |
559 | 590 | | |
560 | 591 | | |
561 | | - | |
562 | | - | |
| 592 | + | |
563 | 593 | | |
564 | 594 | | |
565 | 595 | | |
| |||
0 commit comments