Commit e51321b
committed
make methods on ENV safe if they load an encoding
Most of the time this should work fine, but if a native extension calls
`setlocale(SOME_LOCALE)`, and that encoding is not loaded, it will load
next time `rb_locale_encoding()` is called. This is called for methods on ENV
like ENV#[]. Since these ENV methods acquire the VM lock, we need to
make sure the encoding is loaded prior to locking it.
Calling `setlocale()` like this is supported. The documentation for
`rb_locale_encoding()` states:
```
* This is dynamic. If you change the process' locale by e.g. calling
* `setlocale(3)`, that should also change the return value of this function.
*
* There is no official way for Ruby scripts to manipulate locales, though.
rb_encoding *rb_locale_encoding(void);
```1 parent 042f84b commit e51321b
2 files changed
Lines changed: 26 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
856 | 856 | | |
857 | 857 | | |
858 | 858 | | |
| 859 | + | |
859 | 860 | | |
860 | 861 | | |
861 | 862 | | |
| |||
873 | 874 | | |
874 | 875 | | |
875 | 876 | | |
876 | | - | |
877 | 877 | | |
878 | 878 | | |
879 | 879 | | |
| |||
1556 | 1556 | | |
1557 | 1557 | | |
1558 | 1558 | | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
1559 | 1562 | | |
1560 | 1563 | | |
1561 | 1564 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5192 | 5192 | | |
5193 | 5193 | | |
5194 | 5194 | | |
5195 | | - | |
| 5195 | + | |
5196 | 5196 | | |
5197 | | - | |
| 5197 | + | |
5198 | 5198 | | |
5199 | 5199 | | |
5200 | 5200 | | |
5201 | | - | |
| 5201 | + | |
5202 | 5202 | | |
5203 | 5203 | | |
5204 | | - | |
| 5204 | + | |
5205 | 5205 | | |
5206 | 5206 | | |
5207 | 5207 | | |
5208 | 5208 | | |
5209 | 5209 | | |
5210 | 5210 | | |
| 5211 | + | |
5211 | 5212 | | |
5212 | 5213 | | |
5213 | | - | |
| 5214 | + | |
5214 | 5215 | | |
5215 | 5216 | | |
5216 | 5217 | | |
| |||
5773 | 5774 | | |
5774 | 5775 | | |
5775 | 5776 | | |
| 5777 | + | |
5776 | 5778 | | |
5777 | 5779 | | |
5778 | 5780 | | |
5779 | 5781 | | |
5780 | 5782 | | |
5781 | 5783 | | |
5782 | | - | |
| 5784 | + | |
5783 | 5785 | | |
5784 | 5786 | | |
5785 | 5787 | | |
| |||
5865 | 5867 | | |
5866 | 5868 | | |
5867 | 5869 | | |
| 5870 | + | |
5868 | 5871 | | |
5869 | 5872 | | |
5870 | 5873 | | |
5871 | 5874 | | |
5872 | 5875 | | |
5873 | 5876 | | |
5874 | | - | |
5875 | | - | |
| 5877 | + | |
| 5878 | + | |
5876 | 5879 | | |
5877 | 5880 | | |
5878 | 5881 | | |
| |||
6255 | 6258 | | |
6256 | 6259 | | |
6257 | 6260 | | |
| 6261 | + | |
6258 | 6262 | | |
6259 | 6263 | | |
6260 | 6264 | | |
6261 | 6265 | | |
6262 | 6266 | | |
6263 | | - | |
6264 | | - | |
| 6267 | + | |
| 6268 | + | |
6265 | 6269 | | |
6266 | 6270 | | |
6267 | 6271 | | |
| |||
6509 | 6513 | | |
6510 | 6514 | | |
6511 | 6515 | | |
| 6516 | + | |
6512 | 6517 | | |
6513 | 6518 | | |
6514 | 6519 | | |
6515 | 6520 | | |
6516 | 6521 | | |
6517 | 6522 | | |
6518 | 6523 | | |
6519 | | - | |
| 6524 | + | |
6520 | 6525 | | |
6521 | 6526 | | |
6522 | 6527 | | |
| |||
6533 | 6538 | | |
6534 | 6539 | | |
6535 | 6540 | | |
| 6541 | + | |
6536 | 6542 | | |
6537 | 6543 | | |
6538 | 6544 | | |
6539 | 6545 | | |
6540 | 6546 | | |
6541 | | - | |
6542 | | - | |
| 6547 | + | |
| 6548 | + | |
6543 | 6549 | | |
6544 | 6550 | | |
6545 | 6551 | | |
| |||
6684 | 6690 | | |
6685 | 6691 | | |
6686 | 6692 | | |
| 6693 | + | |
6687 | 6694 | | |
6688 | 6695 | | |
6689 | 6696 | | |
6690 | 6697 | | |
6691 | 6698 | | |
6692 | 6699 | | |
6693 | | - | |
6694 | | - | |
| 6700 | + | |
| 6701 | + | |
6695 | 6702 | | |
6696 | 6703 | | |
6697 | 6704 | | |
| |||
0 commit comments