[#119637] Behavior of raising from rescue blocks when multiple rescue blocks exist — Rodrigo Rosenfeld Rosas via ruby-core <ruby-core@...>
Hello, I couldn't find any documentation about the subject, so I thought
3 messages
2024/10/29
[ruby-core:119649] [Ruby master Bug#20856] Incorrect and inconsistent multi-thread eval execution
From:
"hurricup (Alexandr Evstigneev) via ruby-core" <ruby-core@...>
Date:
2024-10-31 08:30:14 UTC
List:
ruby-core #119649
Issue #20856 has been reported by hurricup (Alexandr Evstigneev).
----------------------------------------
Bug #20856: Incorrect and inconsistent multi-thread eval execution
https://bugs.ruby-lang.org/issues/20856
* Author: hurricup (Alexandr Evstigneev)
* Status: Open
* ruby -v: 3.4.0-preview2
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
Consider example:
```
s = Thread.new {
a = 5
puts eval("a == b")
x = 6
}
s.join
b = 11
```
As far as I see it, it should not work. Because at the moment of eval, b is unknown and not even declared (it can even be in condition).
But it may be available because file `iseq` already compiled and we know that there is b.
So, this works in ruby 3.3 in a script we running, wrapped into the method, or required by other file.
But in 3.4-preview2:
- it works in file
- it works in method
- it fails if required from other file with:
```
#<Thread:0x00007725530d6a98 /home/hurricup/Projects/ruby-debugger/rdi30/test2.rb:1 run> terminated with exception (report_on_exception is true):
(eval at /home/hurricup/Projects/ruby-debugger/rdi30/test2.rb:3):1:in 'block in <top (required)>': undefined local variable or method 'b' for main (NameError)
from /home/hurricup/Projects/ruby-debugger/rdi30/test2.rb:3:in 'Kernel#eval'
from /home/hurricup/Projects/ruby-debugger/rdi30/test2.rb:3:in 'block in <top (required)>'
(eval at /home/hurricup/Projects/ruby-debugger/rdi30/test2.rb:3):1:in 'block in <top (required)>': undefined local variable or method 'b' for main (NameError)
from /home/hurricup/Projects/ruby-debugger/rdi30/test2.rb:3:in 'Kernel#eval'
from /home/hurricup/Projects/ruby-debugger/rdi30/test2.rb:3:in 'block in <top (required)>'
```
And this ^^ is correct behavior if you ask me :) but atm it is inconsistent between the ruby versions and even in the scope of 3.4-preview2
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- [email protected]
To unsubscribe send an email to [email protected]
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/