* [ruby-core:108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces
@ 2022-04-19 14:42 sos4nt
2022-07-29 13:54 ` [ruby-core:109366] " marcper (Marcelo Pereira)
` (18 more replies)
0 siblings, 19 replies; 20+ messages in thread
From: sos4nt @ 2022-04-19 14:42 UTC (permalink / raw)
To: ruby-core
Issue #18743 has been reported by sos4nt (Stefan Schüßler).
----------------------------------------
Bug #18743: Enumerator#next / peek re-use each others stacktraces
https://bugs.ruby-lang.org/issues/18743
* Author: sos4nt (Stefan Schüßler)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I encountered an odd behavior.
If I rescue the `StopIteration` exception from `peek` and call `next` afterwards: (or vice-versa)
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next # 5
```
it will show the stacktrace from the rescued `peek` call:
```
$ ruby enum.rb
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
Whereas the error should refer to `next` on line number 5.
The same happens when calling `peek` after `next` or when having muliple `peek` / `next` calls:
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next rescue nil # 5
enum.peek rescue nil # 6
puts "line #{__LINE__}" # 7
enum.next # 8
```
The stacktrace from the first (rescued) `peek` or `next` call will be shown which doesn't reflect the actual error location:
```
$ ruby enum.rb
line 7
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
This is very confusing when debugging code.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 20+ messages in thread
* [ruby-core:109366] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces
2022-04-19 14:42 [ruby-core:108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces sos4nt
@ 2022-07-29 13:54 ` marcper (Marcelo Pereira)
2022-09-04 14:50 ` [ruby-core:109841] " marcper (Marcelo Pereira)
` (17 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: marcper (Marcelo Pereira) @ 2022-07-29 13:54 UTC (permalink / raw)
To: ruby-core
Issue #18743 has been updated by marcper (Marcelo Pereira).
This issue is part of Ruby for a long time now:
https://github.com/ruby/ruby/commit/3a855da47b867e24428582b0a20aa1ea7e4dc2af
Proposed fix here:
https://github.com/ruby/ruby/pull/6201
----------------------------------------
Bug #18743: Enumerator#next / peek re-use each others stacktraces
https://bugs.ruby-lang.org/issues/18743#change-98509
* Author: sos4nt (Stefan Schüßler)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I encountered an odd behavior.
If I rescue the `StopIteration` exception from `peek` and call `next` afterwards: (or vice-versa)
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next # 5
```
it will show the stacktrace from the rescued `peek` call:
```
$ ruby enum.rb
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
Whereas the error should refer to `next` on line number 5.
The same happens when calling `peek` after `next` or when having muliple `peek` / `next` calls:
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next rescue nil # 5
enum.peek rescue nil # 6
puts "line #{__LINE__}" # 7
enum.next # 8
```
The stacktrace from the first (rescued) `peek` or `next` call will be shown which doesn't reflect the actual error location:
```
$ ruby enum.rb
line 7
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
This is very confusing when debugging code.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 20+ messages in thread
* [ruby-core:109841] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces
2022-04-19 14:42 [ruby-core:108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces sos4nt
2022-07-29 13:54 ` [ruby-core:109366] " marcper (Marcelo Pereira)
@ 2022-09-04 14:50 ` marcper (Marcelo Pereira)
2022-10-06 8:42 ` [ruby-core:110205] " marcper (Marcelo Pereira)
` (16 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: marcper (Marcelo Pereira) @ 2022-09-04 14:50 UTC (permalink / raw)
To: ruby-core
Issue #18743 has been updated by marcper (Marcelo Pereira).
Good day, @matz. Is the fix above acceptable?
----------------------------------------
Bug #18743: Enumerator#next / peek re-use each others stacktraces
https://bugs.ruby-lang.org/issues/18743#change-99079
* Author: sos4nt (Stefan Schüßler)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I encountered an odd behavior.
If I rescue the `StopIteration` exception from `peek` and call `next` afterwards: (or vice-versa)
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next # 5
```
it will show the stacktrace from the rescued `peek` call:
```
$ ruby enum.rb
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
Whereas the error should refer to `next` on line number 5.
The same happens when calling `peek` after `next` or when having muliple `peek` / `next` calls:
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next rescue nil # 5
enum.peek rescue nil # 6
puts "line #{__LINE__}" # 7
enum.next # 8
```
The stacktrace from the first (rescued) `peek` or `next` call will be shown which doesn't reflect the actual error location:
```
$ ruby enum.rb
line 7
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
This is very confusing when debugging code.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 20+ messages in thread
* [ruby-core:110205] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces
2022-04-19 14:42 [ruby-core:108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces sos4nt
2022-07-29 13:54 ` [ruby-core:109366] " marcper (Marcelo Pereira)
2022-09-04 14:50 ` [ruby-core:109841] " marcper (Marcelo Pereira)
@ 2022-10-06 8:42 ` marcper (Marcelo Pereira)
2022-10-23 13:09 ` [ruby-core:110491] " marcper (Marcelo Pereira)
` (15 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: marcper (Marcelo Pereira) @ 2022-10-06 8:42 UTC (permalink / raw)
To: ruby-core
Issue #18743 has been updated by marcper (Marcelo Pereira).
Hello @matz, please let me know if someone else should be pinged for this.
----------------------------------------
Bug #18743: Enumerator#next / peek re-use each others stacktraces
https://bugs.ruby-lang.org/issues/18743#change-99487
* Author: sos4nt (Stefan Schüßler)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I encountered an odd behavior.
If I rescue the `StopIteration` exception from `peek` and call `next` afterwards: (or vice-versa)
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next # 5
```
it will show the stacktrace from the rescued `peek` call:
```
$ ruby enum.rb
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
Whereas the error should refer to `next` on line number 5.
The same happens when calling `peek` after `next` or when having muliple `peek` / `next` calls:
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next rescue nil # 5
enum.peek rescue nil # 6
puts "line #{__LINE__}" # 7
enum.next # 8
```
The stacktrace from the first (rescued) `peek` or `next` call will be shown which doesn't reflect the actual error location:
```
$ ruby enum.rb
line 7
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
This is very confusing when debugging code.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 20+ messages in thread
* [ruby-core:110491] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces
2022-04-19 14:42 [ruby-core:108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces sos4nt
` (2 preceding siblings ...)
2022-10-06 8:42 ` [ruby-core:110205] " marcper (Marcelo Pereira)
@ 2022-10-23 13:09 ` marcper (Marcelo Pereira)
2022-11-09 8:17 ` [ruby-core:110666] " marcper (Marcelo Pereira)
` (14 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: marcper (Marcelo Pereira) @ 2022-10-23 13:09 UTC (permalink / raw)
To: ruby-core
Issue #18743 has been updated by marcper (Marcelo Pereira).
File 01-Recreate-stacktrace-enumerator.patch added
@matz, I'm adding the patch file here as well, following the contributor's guide.
----------------------------------------
Bug #18743: Enumerator#next / peek re-use each others stacktraces
https://bugs.ruby-lang.org/issues/18743#change-99812
* Author: sos4nt (Stefan Schüßler)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I encountered an odd behavior.
If I rescue the `StopIteration` exception from `peek` and call `next` afterwards: (or vice-versa)
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next # 5
```
it will show the stacktrace from the rescued `peek` call:
```
$ ruby enum.rb
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
Whereas the error should refer to `next` on line number 5.
The same happens when calling `peek` after `next` or when having muliple `peek` / `next` calls:
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next rescue nil # 5
enum.peek rescue nil # 6
puts "line #{__LINE__}" # 7
enum.next # 8
```
The stacktrace from the first (rescued) `peek` or `next` call will be shown which doesn't reflect the actual error location:
```
$ ruby enum.rb
line 7
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
This is very confusing when debugging code.
---Files--------------------------------
01-Recreate-stacktrace-enumerator.patch (1.29 KB)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 20+ messages in thread
* [ruby-core:110666] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces
2022-04-19 14:42 [ruby-core:108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces sos4nt
` (3 preceding siblings ...)
2022-10-23 13:09 ` [ruby-core:110491] " marcper (Marcelo Pereira)
@ 2022-11-09 8:17 ` marcper (Marcelo Pereira)
2022-12-29 8:56 ` [ruby-core:111498] " marcper (Marcelo Pereira) via ruby-core
` (13 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: marcper (Marcelo Pereira) @ 2022-11-09 8:17 UTC (permalink / raw)
To: ruby-core
Issue #18743 has been updated by marcper (Marcelo Pereira).
Pinging @matz. Sorry if I'm being annoying, but the contributor guide says I should send a reminder after a few weeks if there's no response.
----------------------------------------
Bug #18743: Enumerator#next / peek re-use each others stacktraces
https://bugs.ruby-lang.org/issues/18743#change-100010
* Author: sos4nt (Stefan Schüßler)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I encountered an odd behavior.
If I rescue the `StopIteration` exception from `peek` and call `next` afterwards: (or vice-versa)
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next # 5
```
it will show the stacktrace from the rescued `peek` call:
```
$ ruby enum.rb
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
Whereas the error should refer to `next` on line number 5.
The same happens when calling `peek` after `next` or when having muliple `peek` / `next` calls:
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next rescue nil # 5
enum.peek rescue nil # 6
puts "line #{__LINE__}" # 7
enum.next # 8
```
The stacktrace from the first (rescued) `peek` or `next` call will be shown which doesn't reflect the actual error location:
```
$ ruby enum.rb
line 7
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
This is very confusing when debugging code.
---Files--------------------------------
01-Recreate-stacktrace-enumerator.patch (1.29 KB)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 20+ messages in thread
* [ruby-core:111498] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces
2022-04-19 14:42 [ruby-core:108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces sos4nt
` (4 preceding siblings ...)
2022-11-09 8:17 ` [ruby-core:110666] " marcper (Marcelo Pereira)
@ 2022-12-29 8:56 ` marcper (Marcelo Pereira) via ruby-core
2023-03-03 8:58 ` [ruby-core:112675] " marcper (Marcelo Pereira) via ruby-core
` (12 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: marcper (Marcelo Pereira) via ruby-core @ 2022-12-29 8:56 UTC (permalink / raw)
To: ruby-core; +Cc: marcper (Marcelo Pereira)
Issue #18743 has been updated by marcper (Marcelo Pereira).
Good evening, @matz. The PR with the bug fix is available now for a few months. Please advise on the next steps.
----------------------------------------
Bug #18743: Enumerator#next / peek re-use each others stacktraces
https://bugs.ruby-lang.org/issues/18743#change-100867
* Author: sos4nt (Stefan Schüßler)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I encountered an odd behavior.
If I rescue the `StopIteration` exception from `peek` and call `next` afterwards: (or vice-versa)
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next # 5
```
it will show the stacktrace from the rescued `peek` call:
```
$ ruby enum.rb
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
Whereas the error should refer to `next` on line number 5.
The same happens when calling `peek` after `next` or when having muliple `peek` / `next` calls:
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next rescue nil # 5
enum.peek rescue nil # 6
puts "line #{__LINE__}" # 7
enum.next # 8
```
The stacktrace from the first (rescued) `peek` or `next` call will be shown which doesn't reflect the actual error location:
```
$ ruby enum.rb
line 7
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
This is very confusing when debugging code.
---Files--------------------------------
01-Recreate-stacktrace-enumerator.patch (1.29 KB)
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 20+ messages in thread
* [ruby-core:112675] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces
2022-04-19 14:42 [ruby-core:108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces sos4nt
` (5 preceding siblings ...)
2022-12-29 8:56 ` [ruby-core:111498] " marcper (Marcelo Pereira) via ruby-core
@ 2023-03-03 8:58 ` marcper (Marcelo Pereira) via ruby-core
2023-03-09 6:26 ` [ruby-core:112763] " ko1 (Koichi Sasada) via ruby-core
` (11 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: marcper (Marcelo Pereira) via ruby-core @ 2023-03-03 8:58 UTC (permalink / raw)
To: ruby-core; +Cc: marcper (Marcelo Pereira)
Issue #18743 has been updated by marcper (Marcelo Pereira).
@sos4nt could you please assign this issue to @matz? This is a core class problem, and he is the listed maintainer for it.
I can confirm the bug still exists in ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-linux]
----------------------------------------
Bug #18743: Enumerator#next / peek re-use each others stacktraces
https://bugs.ruby-lang.org/issues/18743#change-102126
* Author: sos4nt (Stefan Schüßler)
* Status: Open
* Priority: Normal
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I encountered an odd behavior.
If I rescue the `StopIteration` exception from `peek` and call `next` afterwards: (or vice-versa)
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next # 5
```
it will show the stacktrace from the rescued `peek` call:
```
$ ruby enum.rb
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
Whereas the error should refer to `next` on line number 5.
The same happens when calling `peek` after `next` or when having muliple `peek` / `next` calls:
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next rescue nil # 5
enum.peek rescue nil # 6
puts "line #{__LINE__}" # 7
enum.next # 8
```
The stacktrace from the first (rescued) `peek` or `next` call will be shown which doesn't reflect the actual error location:
```
$ ruby enum.rb
line 7
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
This is very confusing when debugging code.
---Files--------------------------------
01-Recreate-stacktrace-enumerator.patch (1.29 KB)
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 20+ messages in thread
* [ruby-core:112763] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces
2022-04-19 14:42 [ruby-core:108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces sos4nt
` (6 preceding siblings ...)
2023-03-03 8:58 ` [ruby-core:112675] " marcper (Marcelo Pereira) via ruby-core
@ 2023-03-09 6:26 ` ko1 (Koichi Sasada) via ruby-core
2023-03-10 3:35 ` [ruby-core:112820] " matz (Yukihiro Matsumoto) via ruby-core
` (10 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: ko1 (Koichi Sasada) via ruby-core @ 2023-03-09 6:26 UTC (permalink / raw)
To: ruby-core; +Cc: ko1 (Koichi Sasada)
Issue #18743 has been updated by ko1 (Koichi Sasada).
Assignee set to ko1 (Koichi Sasada)
----------------------------------------
Bug #18743: Enumerator#next / peek re-use each others stacktraces
https://bugs.ruby-lang.org/issues/18743#change-102258
* Author: sos4nt (Stefan Schüßler)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I encountered an odd behavior.
If I rescue the `StopIteration` exception from `peek` and call `next` afterwards: (or vice-versa)
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next # 5
```
it will show the stacktrace from the rescued `peek` call:
```
$ ruby enum.rb
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
Whereas the error should refer to `next` on line number 5.
The same happens when calling `peek` after `next` or when having muliple `peek` / `next` calls:
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next rescue nil # 5
enum.peek rescue nil # 6
puts "line #{__LINE__}" # 7
enum.next # 8
```
The stacktrace from the first (rescued) `peek` or `next` call will be shown which doesn't reflect the actual error location:
```
$ ruby enum.rb
line 7
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
This is very confusing when debugging code.
---Files--------------------------------
01-Recreate-stacktrace-enumerator.patch (1.29 KB)
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 20+ messages in thread
* [ruby-core:112820] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces
2022-04-19 14:42 [ruby-core:108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces sos4nt
` (7 preceding siblings ...)
2023-03-09 6:26 ` [ruby-core:112763] " ko1 (Koichi Sasada) via ruby-core
@ 2023-03-10 3:35 ` matz (Yukihiro Matsumoto) via ruby-core
2023-03-18 14:28 ` [ruby-core:112941] " marcper (Marcelo Pereira) via ruby-core
` (9 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: matz (Yukihiro Matsumoto) via ruby-core @ 2023-03-10 3:35 UTC (permalink / raw)
To: ruby-core; +Cc: matz (Yukihiro Matsumoto)
Issue #18743 has been updated by matz (Yukihiro Matsumoto).
It should be fixed. But I think the proposed change https://github.com/ruby/ruby/pull/6201 is not enough, we should link the old exception with the new one (via `cause`).
Matz.
----------------------------------------
Bug #18743: Enumerator#next / peek re-use each others stacktraces
https://bugs.ruby-lang.org/issues/18743#change-102327
* Author: sos4nt (Stefan Schüßler)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I encountered an odd behavior.
If I rescue the `StopIteration` exception from `peek` and call `next` afterwards: (or vice-versa)
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next # 5
```
it will show the stacktrace from the rescued `peek` call:
```
$ ruby enum.rb
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
Whereas the error should refer to `next` on line number 5.
The same happens when calling `peek` after `next` or when having muliple `peek` / `next` calls:
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next rescue nil # 5
enum.peek rescue nil # 6
puts "line #{__LINE__}" # 7
enum.next # 8
```
The stacktrace from the first (rescued) `peek` or `next` call will be shown which doesn't reflect the actual error location:
```
$ ruby enum.rb
line 7
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
This is very confusing when debugging code.
---Files--------------------------------
01-Recreate-stacktrace-enumerator.patch (1.29 KB)
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 20+ messages in thread
* [ruby-core:112941] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces
2022-04-19 14:42 [ruby-core:108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces sos4nt
` (8 preceding siblings ...)
2023-03-10 3:35 ` [ruby-core:112820] " matz (Yukihiro Matsumoto) via ruby-core
@ 2023-03-18 14:28 ` marcper (Marcelo Pereira) via ruby-core
2023-04-01 10:10 ` [ruby-core:113069] " marcper (Marcelo Pereira) via ruby-core
` (8 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: marcper (Marcelo Pereira) via ruby-core @ 2023-03-18 14:28 UTC (permalink / raw)
To: ruby-core; +Cc: marcper (Marcelo Pereira)
Issue #18743 has been updated by marcper (Marcelo Pereira).
Hello again. I've modified the patch to also link to the old exception via `cause`. Let me know if it's now a reasonable solution.
Thanks,
Marcelo
----------------------------------------
Bug #18743: Enumerator#next / peek re-use each others stacktraces
https://bugs.ruby-lang.org/issues/18743#change-102465
* Author: sos4nt (Stefan Schüßler)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I encountered an odd behavior.
If I rescue the `StopIteration` exception from `peek` and call `next` afterwards: (or vice-versa)
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next # 5
```
it will show the stacktrace from the rescued `peek` call:
```
$ ruby enum.rb
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
Whereas the error should refer to `next` on line number 5.
The same happens when calling `peek` after `next` or when having muliple `peek` / `next` calls:
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next rescue nil # 5
enum.peek rescue nil # 6
puts "line #{__LINE__}" # 7
enum.next # 8
```
The stacktrace from the first (rescued) `peek` or `next` call will be shown which doesn't reflect the actual error location:
```
$ ruby enum.rb
line 7
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
This is very confusing when debugging code.
---Files--------------------------------
01-Recreate-stacktrace-enumerator.patch (1.29 KB)
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 20+ messages in thread
* [ruby-core:113069] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces
2022-04-19 14:42 [ruby-core:108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces sos4nt
` (9 preceding siblings ...)
2023-03-18 14:28 ` [ruby-core:112941] " marcper (Marcelo Pereira) via ruby-core
@ 2023-04-01 10:10 ` marcper (Marcelo Pereira) via ruby-core
2023-05-16 13:03 ` [ruby-core:113497] " marcper (Marcelo Pereira) via ruby-core
` (7 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: marcper (Marcelo Pereira) via ruby-core @ 2023-04-01 10:10 UTC (permalink / raw)
To: ruby-core; +Cc: marcper (Marcelo Pereira)
Issue #18743 has been updated by marcper (Marcelo Pereira).
Hello @ko1, let me know if the patch in the current form is acceptable.
Best,
Marcelo
----------------------------------------
Bug #18743: Enumerator#next / peek re-use each others stacktraces
https://bugs.ruby-lang.org/issues/18743#change-102602
* Author: sos4nt (Stefan Schüßler)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I encountered an odd behavior.
If I rescue the `StopIteration` exception from `peek` and call `next` afterwards: (or vice-versa)
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next # 5
```
it will show the stacktrace from the rescued `peek` call:
```
$ ruby enum.rb
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
Whereas the error should refer to `next` on line number 5.
The same happens when calling `peek` after `next` or when having muliple `peek` / `next` calls:
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next rescue nil # 5
enum.peek rescue nil # 6
puts "line #{__LINE__}" # 7
enum.next # 8
```
The stacktrace from the first (rescued) `peek` or `next` call will be shown which doesn't reflect the actual error location:
```
$ ruby enum.rb
line 7
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
This is very confusing when debugging code.
---Files--------------------------------
01-Recreate-stacktrace-enumerator.patch (1.29 KB)
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 20+ messages in thread
* [ruby-core:113497] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces
2022-04-19 14:42 [ruby-core:108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces sos4nt
` (10 preceding siblings ...)
2023-04-01 10:10 ` [ruby-core:113069] " marcper (Marcelo Pereira) via ruby-core
@ 2023-05-16 13:03 ` marcper (Marcelo Pereira) via ruby-core
2023-05-17 2:03 ` [ruby-core:113501] " nobu (Nobuyoshi Nakada) via ruby-core
` (6 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: marcper (Marcelo Pereira) via ruby-core @ 2023-05-16 13:03 UTC (permalink / raw)
To: ruby-core; +Cc: marcper (Marcelo Pereira)
Issue #18743 has been updated by marcper (Marcelo Pereira).
Hey again, @ko1. This is just a reminder that the patch is pushed to Github and is waiting for a decision.
Best,
Marcelo
----------------------------------------
Bug #18743: Enumerator#next / peek re-use each others stacktraces
https://bugs.ruby-lang.org/issues/18743#change-103093
* Author: sos4nt (Stefan Schüßler)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I encountered an odd behavior.
If I rescue the `StopIteration` exception from `peek` and call `next` afterwards: (or vice-versa)
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next # 5
```
it will show the stacktrace from the rescued `peek` call:
```
$ ruby enum.rb
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
Whereas the error should refer to `next` on line number 5.
The same happens when calling `peek` after `next` or when having muliple `peek` / `next` calls:
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next rescue nil # 5
enum.peek rescue nil # 6
puts "line #{__LINE__}" # 7
enum.next # 8
```
The stacktrace from the first (rescued) `peek` or `next` call will be shown which doesn't reflect the actual error location:
```
$ ruby enum.rb
line 7
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
This is very confusing when debugging code.
---Files--------------------------------
01-Recreate-stacktrace-enumerator.patch (1.29 KB)
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 20+ messages in thread
* [ruby-core:113501] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces
2022-04-19 14:42 [ruby-core:108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces sos4nt
` (11 preceding siblings ...)
2023-05-16 13:03 ` [ruby-core:113497] " marcper (Marcelo Pereira) via ruby-core
@ 2023-05-17 2:03 ` nobu (Nobuyoshi Nakada) via ruby-core
2023-05-19 14:55 ` [ruby-core:113531] " marcper (Marcelo Pereira) via ruby-core
` (5 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2023-05-17 2:03 UTC (permalink / raw)
To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)
Issue #18743 has been updated by nobu (Nobuyoshi Nakada).
Seems find to me.
One thing I concerned, `stop_exc` will be re-created every times, and no way to know where it was first used up.
How about chaining by `cause`?
```diff
diff --git a/enumerator.c b/enumerator.c
index b33c1713718..1cc8f9108cf 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -30,6 +30,9 @@
#include "internal/rational.h"
#include "ruby/ruby.h"
+extern ID ruby_static_id_cause;
+#define id_cause ruby_static_id_cause
+
/*
* Document-class: Enumerator
*
@@ -787,8 +790,16 @@ get_next_values(VALUE obj, struct enumerator *e)
{
VALUE curr, vs;
- if (e->stop_exc)
- rb_exc_raise(e->stop_exc);
+ if (e->stop_exc) {
+ VALUE exc = e->stop_exc;
+ VALUE result = rb_attr_get(exc, id_result);
+ VALUE mesg = rb_attr_get(exc, idMesg);
+ if (!NIL_P(mesg)) mesg = rb_str_dup(mesg);
+ VALUE stop_exc = rb_exc_new_str(rb_eStopIteration, mesg);
+ rb_ivar_set(stop_exc, id_result, result);
+ rb_ivar_set(stop_exc, id_cause, exc);
+ rb_exc_raise(stop_exc);
+ }
curr = rb_fiber_current();
```
In the test, save `$!` at the first `rescue` then `assert_same(cause, exc.cause)`.
----------------------------------------
Bug #18743: Enumerator#next / peek re-use each others stacktraces
https://bugs.ruby-lang.org/issues/18743#change-103096
* Author: sos4nt (Stefan Schüßler)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I encountered an odd behavior.
If I rescue the `StopIteration` exception from `peek` and call `next` afterwards: (or vice-versa)
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next # 5
```
it will show the stacktrace from the rescued `peek` call:
```
$ ruby enum.rb
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
Whereas the error should refer to `next` on line number 5.
The same happens when calling `peek` after `next` or when having muliple `peek` / `next` calls:
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next rescue nil # 5
enum.peek rescue nil # 6
puts "line #{__LINE__}" # 7
enum.next # 8
```
The stacktrace from the first (rescued) `peek` or `next` call will be shown which doesn't reflect the actual error location:
```
$ ruby enum.rb
line 7
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
This is very confusing when debugging code.
---Files--------------------------------
01-Recreate-stacktrace-enumerator.patch (1.29 KB)
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 20+ messages in thread
* [ruby-core:113531] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces
2022-04-19 14:42 [ruby-core:108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces sos4nt
` (12 preceding siblings ...)
2023-05-17 2:03 ` [ruby-core:113501] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2023-05-19 14:55 ` marcper (Marcelo Pereira) via ruby-core
2023-06-07 6:48 ` [ruby-core:113786] " nobu (Nobuyoshi Nakada) via ruby-core
` (4 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: marcper (Marcelo Pereira) via ruby-core @ 2023-05-19 14:55 UTC (permalink / raw)
To: ruby-core; +Cc: marcper (Marcelo Pereira)
Issue #18743 has been updated by marcper (Marcelo Pereira).
The exceptions are already being chained through `cause`, but I've just updated the tests to make this fact clearer.
Indeed a new exception is created every time. Initially I looked for an API to simply update the backtrace on the existing exception, and couldn't find one. But given the need to chain exceptions, creating a new one every time turned out to be the right approach.
Thank you for reviewing this, @nobu, and I'm happy to address any other concerns.
----------------------------------------
Bug #18743: Enumerator#next / peek re-use each others stacktraces
https://bugs.ruby-lang.org/issues/18743#change-103158
* Author: sos4nt (Stefan Schüßler)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I encountered an odd behavior.
If I rescue the `StopIteration` exception from `peek` and call `next` afterwards: (or vice-versa)
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next # 5
```
it will show the stacktrace from the rescued `peek` call:
```
$ ruby enum.rb
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
Whereas the error should refer to `next` on line number 5.
The same happens when calling `peek` after `next` or when having muliple `peek` / `next` calls:
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next rescue nil # 5
enum.peek rescue nil # 6
puts "line #{__LINE__}" # 7
enum.next # 8
```
The stacktrace from the first (rescued) `peek` or `next` call will be shown which doesn't reflect the actual error location:
```
$ ruby enum.rb
line 7
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
This is very confusing when debugging code.
---Files--------------------------------
01-Recreate-stacktrace-enumerator.patch (1.29 KB)
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 20+ messages in thread
* [ruby-core:113786] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces
2022-04-19 14:42 [ruby-core:108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces sos4nt
` (13 preceding siblings ...)
2023-05-19 14:55 ` [ruby-core:113531] " marcper (Marcelo Pereira) via ruby-core
@ 2023-06-07 6:48 ` nobu (Nobuyoshi Nakada) via ruby-core
2023-06-26 19:41 ` [ruby-core:114024] " marcper (Marcelo Pereira) via ruby-core
` (3 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2023-06-07 6:48 UTC (permalink / raw)
To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)
Issue #18743 has been updated by nobu (Nobuyoshi Nakada).
Your PR makes `stop_exc` to be overwritten for each `StopIteration`.
IMO, it should not change and the `cause` of all subsequent `StopIteration`s should be the same first exception.
----------------------------------------
Bug #18743: Enumerator#next / peek re-use each others stacktraces
https://bugs.ruby-lang.org/issues/18743#change-103434
* Author: sos4nt (Stefan Schüßler)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I encountered an odd behavior.
If I rescue the `StopIteration` exception from `peek` and call `next` afterwards: (or vice-versa)
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next # 5
```
it will show the stacktrace from the rescued `peek` call:
```
$ ruby enum.rb
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
Whereas the error should refer to `next` on line number 5.
The same happens when calling `peek` after `next` or when having muliple `peek` / `next` calls:
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next rescue nil # 5
enum.peek rescue nil # 6
puts "line #{__LINE__}" # 7
enum.next # 8
```
The stacktrace from the first (rescued) `peek` or `next` call will be shown which doesn't reflect the actual error location:
```
$ ruby enum.rb
line 7
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
This is very confusing when debugging code.
---Files--------------------------------
01-Recreate-stacktrace-enumerator.patch (1.29 KB)
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 20+ messages in thread
* [ruby-core:114024] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces
2022-04-19 14:42 [ruby-core:108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces sos4nt
` (14 preceding siblings ...)
2023-06-07 6:48 ` [ruby-core:113786] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2023-06-26 19:41 ` marcper (Marcelo Pereira) via ruby-core
2023-07-14 12:09 ` [ruby-core:114185] " marcper (Marcelo Pereira) via ruby-core
` (2 subsequent siblings)
18 siblings, 0 replies; 20+ messages in thread
From: marcper (Marcelo Pereira) via ruby-core @ 2023-06-26 19:41 UTC (permalink / raw)
To: ruby-core; +Cc: marcper (Marcelo Pereira)
Issue #18743 has been updated by marcper (Marcelo Pereira).
Oh, I understood from Matz's initial suggestion that the exceptions should be chained, but I see now what he meant. I've applied the changes you suggested, @nobu. Thank you for clarifying, and for reviewing.
----------------------------------------
Bug #18743: Enumerator#next / peek re-use each others stacktraces
https://bugs.ruby-lang.org/issues/18743#change-103688
* Author: sos4nt (Stefan Schüßler)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I encountered an odd behavior.
If I rescue the `StopIteration` exception from `peek` and call `next` afterwards: (or vice-versa)
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next # 5
```
it will show the stacktrace from the rescued `peek` call:
```
$ ruby enum.rb
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
Whereas the error should refer to `next` on line number 5.
The same happens when calling `peek` after `next` or when having muliple `peek` / `next` calls:
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next rescue nil # 5
enum.peek rescue nil # 6
puts "line #{__LINE__}" # 7
enum.next # 8
```
The stacktrace from the first (rescued) `peek` or `next` call will be shown which doesn't reflect the actual error location:
```
$ ruby enum.rb
line 7
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
This is very confusing when debugging code.
---Files--------------------------------
01-Recreate-stacktrace-enumerator.patch (1.29 KB)
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 20+ messages in thread
* [ruby-core:114185] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces
2022-04-19 14:42 [ruby-core:108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces sos4nt
` (15 preceding siblings ...)
2023-06-26 19:41 ` [ruby-core:114024] " marcper (Marcelo Pereira) via ruby-core
@ 2023-07-14 12:09 ` marcper (Marcelo Pereira) via ruby-core
2023-10-29 11:38 ` [ruby-core:115195] " marcper (Marcelo Pereira) via ruby-core
2024-02-25 9:29 ` [ruby-core:116935] " nagachika (Tomoyuki Chikanaga) via ruby-core
18 siblings, 0 replies; 20+ messages in thread
From: marcper (Marcelo Pereira) via ruby-core @ 2023-07-14 12:09 UTC (permalink / raw)
To: ruby-core; +Cc: marcper (Marcelo Pereira)
Issue #18743 has been updated by marcper (Marcelo Pereira).
Hello again, @ko1. Please let me know if this patch is acceptable. I followed the suggestions from @nobu already.
Best
----------------------------------------
Bug #18743: Enumerator#next / peek re-use each others stacktraces
https://bugs.ruby-lang.org/issues/18743#change-103872
* Author: sos4nt (Stefan Schüßler)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I encountered an odd behavior.
If I rescue the `StopIteration` exception from `peek` and call `next` afterwards: (or vice-versa)
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next # 5
```
it will show the stacktrace from the rescued `peek` call:
```
$ ruby enum.rb
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
Whereas the error should refer to `next` on line number 5.
The same happens when calling `peek` after `next` or when having muliple `peek` / `next` calls:
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next rescue nil # 5
enum.peek rescue nil # 6
puts "line #{__LINE__}" # 7
enum.next # 8
```
The stacktrace from the first (rescued) `peek` or `next` call will be shown which doesn't reflect the actual error location:
```
$ ruby enum.rb
line 7
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
This is very confusing when debugging code.
---Files--------------------------------
01-Recreate-stacktrace-enumerator.patch (1.29 KB)
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 20+ messages in thread
* [ruby-core:115195] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces
2022-04-19 14:42 [ruby-core:108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces sos4nt
` (16 preceding siblings ...)
2023-07-14 12:09 ` [ruby-core:114185] " marcper (Marcelo Pereira) via ruby-core
@ 2023-10-29 11:38 ` marcper (Marcelo Pereira) via ruby-core
2024-02-25 9:29 ` [ruby-core:116935] " nagachika (Tomoyuki Chikanaga) via ruby-core
18 siblings, 0 replies; 20+ messages in thread
From: marcper (Marcelo Pereira) via ruby-core @ 2023-10-29 11:38 UTC (permalink / raw)
To: ruby-core; +Cc: marcper (Marcelo Pereira)
Issue #18743 has been updated by marcper (Marcelo Pereira).
Hi @nobu, and @ko1. The change was merged in July. Shouldn't this issue be closed?
----------------------------------------
Bug #18743: Enumerator#next / peek re-use each others stacktraces
https://bugs.ruby-lang.org/issues/18743#change-105109
* Author: sos4nt (Stefan Schüßler)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I encountered an odd behavior.
If I rescue the `StopIteration` exception from `peek` and call `next` afterwards: (or vice-versa)
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next # 5
```
it will show the stacktrace from the rescued `peek` call:
```
$ ruby enum.rb
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
Whereas the error should refer to `next` on line number 5.
The same happens when calling `peek` after `next` or when having muliple `peek` / `next` calls:
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next rescue nil # 5
enum.peek rescue nil # 6
puts "line #{__LINE__}" # 7
enum.next # 8
```
The stacktrace from the first (rescued) `peek` or `next` call will be shown which doesn't reflect the actual error location:
```
$ ruby enum.rb
line 7
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
This is very confusing when debugging code.
---Files--------------------------------
01-Recreate-stacktrace-enumerator.patch (1.29 KB)
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 20+ messages in thread
* [ruby-core:116935] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces
2022-04-19 14:42 [ruby-core:108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces sos4nt
` (17 preceding siblings ...)
2023-10-29 11:38 ` [ruby-core:115195] " marcper (Marcelo Pereira) via ruby-core
@ 2024-02-25 9:29 ` nagachika (Tomoyuki Chikanaga) via ruby-core
18 siblings, 0 replies; 20+ messages in thread
From: nagachika (Tomoyuki Chikanaga) via ruby-core @ 2024-02-25 9:29 UTC (permalink / raw)
To: ruby-core; +Cc: nagachika (Tomoyuki Chikanaga)
Issue #18743 has been updated by nagachika (Tomoyuki Chikanaga).
Backport changed from 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED to 3.0: REQUIRED, 3.1: REQUIRED, 3.2: DONE
ruby_3_2 5e4606423da96c2e26b00981c22bddfce0d970bf merged revision(s) f15123c34ce80f3928612befe2a9aaf4c9d27fda.
----------------------------------------
Bug #18743: Enumerator#next / peek re-use each others stacktraces
https://bugs.ruby-lang.org/issues/18743#change-106970
* Author: sos4nt (Stefan Schüßler)
* Status: Closed
* Assignee: ko1 (Koichi Sasada)
* Backport: 3.0: REQUIRED, 3.1: REQUIRED, 3.2: DONE
----------------------------------------
I encountered an odd behavior.
If I rescue the `StopIteration` exception from `peek` and call `next` afterwards: (or vice-versa)
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next # 5
```
it will show the stacktrace from the rescued `peek` call:
```
$ ruby enum.rb
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
Whereas the error should refer to `next` on line number 5.
The same happens when calling `peek` after `next` or when having muliple `peek` / `next` calls:
```ruby
# enum.rb # 1
# 2
enum = [].each # 3
enum.peek rescue nil # 4
enum.next rescue nil # 5
enum.peek rescue nil # 6
puts "line #{__LINE__}" # 7
enum.next # 8
```
The stacktrace from the first (rescued) `peek` or `next` call will be shown which doesn't reflect the actual error location:
```
$ ruby enum.rb
line 7
enum.rb:4:in `peek': iteration reached an end (StopIteration)
from enum.rb:4:in `<main>'
```
This is very confusing when debugging code.
---Files--------------------------------
01-Recreate-stacktrace-enumerator.patch (1.29 KB)
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2024-02-25 9:29 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-19 14:42 [ruby-core:108294] [Ruby master Bug#18743] Enumerator#next / peek re-use each others stacktraces sos4nt
2022-07-29 13:54 ` [ruby-core:109366] " marcper (Marcelo Pereira)
2022-09-04 14:50 ` [ruby-core:109841] " marcper (Marcelo Pereira)
2022-10-06 8:42 ` [ruby-core:110205] " marcper (Marcelo Pereira)
2022-10-23 13:09 ` [ruby-core:110491] " marcper (Marcelo Pereira)
2022-11-09 8:17 ` [ruby-core:110666] " marcper (Marcelo Pereira)
2022-12-29 8:56 ` [ruby-core:111498] " marcper (Marcelo Pereira) via ruby-core
2023-03-03 8:58 ` [ruby-core:112675] " marcper (Marcelo Pereira) via ruby-core
2023-03-09 6:26 ` [ruby-core:112763] " ko1 (Koichi Sasada) via ruby-core
2023-03-10 3:35 ` [ruby-core:112820] " matz (Yukihiro Matsumoto) via ruby-core
2023-03-18 14:28 ` [ruby-core:112941] " marcper (Marcelo Pereira) via ruby-core
2023-04-01 10:10 ` [ruby-core:113069] " marcper (Marcelo Pereira) via ruby-core
2023-05-16 13:03 ` [ruby-core:113497] " marcper (Marcelo Pereira) via ruby-core
2023-05-17 2:03 ` [ruby-core:113501] " nobu (Nobuyoshi Nakada) via ruby-core
2023-05-19 14:55 ` [ruby-core:113531] " marcper (Marcelo Pereira) via ruby-core
2023-06-07 6:48 ` [ruby-core:113786] " nobu (Nobuyoshi Nakada) via ruby-core
2023-06-26 19:41 ` [ruby-core:114024] " marcper (Marcelo Pereira) via ruby-core
2023-07-14 12:09 ` [ruby-core:114185] " marcper (Marcelo Pereira) via ruby-core
2023-10-29 11:38 ` [ruby-core:115195] " marcper (Marcelo Pereira) via ruby-core
2024-02-25 9:29 ` [ruby-core:116935] " nagachika (Tomoyuki Chikanaga) via ruby-core
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).