< :前の番号
^ :番号順リスト
> :次の番号
P :前の記事(スレッド移動)
N :次の記事(スレッド移動)
|<:前のスレッド
>|:次のスレッド
^ :返事先
_:自分への返事
>:同じ返事先を持つ記事(前)
<:同じ返事先を持つ記事(後)
---:分割してスレッド表示、再表示
| :分割して(縦)スレッド表示、再表示
~ :スレッドのフレーム消去
.:インデックス
..:インデックスのインデックス
Issue #14353 has been reported by Eregon (Benoit Daloze).
----------------------------------------
Bug #14353: $SAFE should stay at least thread-local for compatibility
https://bugs.ruby-lang.org/issues/14353
* Author: Eregon (Benoit Daloze)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v:
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
In #14250 $SAFE changed from a frame+thread-local variable to a process-wide global variable.
This feels wrong and breaks the most common usage of $SAFE in tests:
~~~ ruby
Thread.new {
$SAFE = 1
sth that should be checked to work under $SAFE==1
}.join
~~~
It is very clear this is incompatible given how many files (33!) had to be changed in r61510.
And it has wide ranging confusing side-effects, one example: https://travis-ci.org/ruby/spec/jobs/328524568
I agree frame-local is too much for $SAFE.
But removing thread-local seems to only introduce large incompatibilities.
It also makes it impossible to use it in a thread-safe way.
The common pattern (not necessarily for $SAFE, more often for $VERBOSE):
~~~ ruby
begin
old = $SAFE
$SAFE = 1
something under SAFE==1
ensure
$SAFE = old
end
~~~
is unsafe if two threads run it concurrently (The last thread executing `$SAFE = old` might restore to 1 even though it should be 0).
(Actually I believe most built-in variables (e.g. $VERBOSE) should be thread-local and not process-wide due to this)
Since $SAFE is being deprecated and removed, I don't see any reason to make it more incompatible than needed.
@ko1 Can we switch it back to thread-local for compatibility, avoiding headaches and keeping it usable with multiple threads?
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>