Commit 2e8459e
committed
Singleton classes of unshareable objects are not shareable
Currently, all RClasses are created as shareable in `class_alloc0`,
which causes singleton classes of unshareable objects to be shareable
which allows passing unshareable objects by passing their singleton
class and getting their attached object.
This changes `singleton_class_of` to mark the singleton class as shareable
when the object is shareable, and inversely, to mark the singleton class as
unshareable if the object is unshareable.
We also need to not forcibly mark the class as shareable in
`shareable_p_enter`.
Additionally, if the object is not yet marked as shareable, but is
frozen (and `allow_frozen_shareable_p`), it becomes marked as shareable
through `rb_ractor_shareable_p`, and we need to also mark its singleton
class as shareable at that point.1 parent 8c7e6f2 commit 2e8459e
3 files changed
+20
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
2864 | 2865 | | |
2865 | 2866 | | |
2866 | 2867 | | |
| 2868 | + | |
| 2869 | + | |
| 2870 | + | |
| 2871 | + | |
| 2872 | + | |
| 2873 | + | |
2867 | 2874 | | |
2868 | 2875 | | |
2869 | 2876 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12523 | 12523 | | |
12524 | 12524 | | |
12525 | 12525 | | |
| 12526 | + | |
12526 | 12527 | | |
12527 | 12528 | | |
12528 | 12529 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
1540 | 1541 | | |
1541 | 1542 | | |
1542 | 1543 | | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
1543 | 1547 | | |
1544 | 1548 | | |
1545 | 1549 | | |
| |||
1587 | 1591 | | |
1588 | 1592 | | |
1589 | 1593 | | |
1590 | | - | |
1591 | | - | |
1592 | | - | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
1593 | 1602 | | |
1594 | 1603 | | |
1595 | 1604 | | |
| |||
0 commit comments