[ruby-core:126049] [Ruby Bug#22191] `Signal.trap(:EXIT)` exception only shown if `at_exit` also raises
Issue #22191 has been reported by Earlopain (Earlopain _). ---------------------------------------- Bug #22191: `Signal.trap(:EXIT)` exception only shown if `at_exit` also raises https://bugs.ruby-lang.org/issues/22191 * Author: Earlopain (Earlopain _) * Status: Open * ruby -v: ruby 4.1.0dev (2026-05-29T14:34:40Z master 7a07a54298) +PRISM [x86_64-linux] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- ```rb Signal.trap(:EXIT, proc { raise "foo" }) # No output ``` ```rb Signal.trap(:EXIT, proc { raise "foo" }) at_exit { raise "bar" } # test.rb:2:in 'block in <main>': bar (RuntimeError) # test.rb:1:in 'block in <main>': foo (RuntimeError) ``` A bit weird -- https://bugs.ruby-lang.org/
Issue #22191 has been updated by nobu (Nobuyoshi Nakada). Related bug: when two `END` raise exceptions, the same message is printed multiple times. ```console $ ruby -e 'END{raise "END1"};END{raise "END2"}' -e:1:in 'block (2 levels) in <main>': END2 (RuntimeError) -e:1:in 'block (2 levels) in <main>': END1 (RuntimeError) -e:1:in 'block (2 levels) in <main>': END2 (RuntimeError) ``` ```console $ ruby -e 'END{raise "END1"};END{raise "END2"};END{raise "END3"}' -e:1:in 'block (2 levels) in <main>': END3 (RuntimeError) -e:1:in 'block (2 levels) in <main>': END2 (RuntimeError) -e:1:in 'block (2 levels) in <main>': END3 (RuntimeError) -e:1:in 'block (2 levels) in <main>': END1 (RuntimeError) -e:1:in 'block (2 levels) in <main>': END2 (RuntimeError) -e:1:in 'block (2 levels) in <main>': END3 (RuntimeError) ``` ---------------------------------------- Bug #22191: `Signal.trap(:EXIT)` exception only shown if `at_exit` also raises https://bugs.ruby-lang.org/issues/22191#change-118062 * Author: Earlopain (Earlopain _) * Status: Open * ruby -v: ruby 4.1.0dev (2026-05-29T14:34:40Z master 7a07a54298) +PRISM [x86_64-linux] * Backport: 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED ---------------------------------------- ```rb Signal.trap(:EXIT, proc { raise "foo" }) # No output ``` ```rb Signal.trap(:EXIT, proc { raise "foo" }) at_exit { raise "bar" } # test.rb:2:in 'block in <main>': bar (RuntimeError) # test.rb:1:in 'block in <main>': foo (RuntimeError) ``` A bit weird -- https://bugs.ruby-lang.org/
Issue #22191 has been updated by k0kubun (Takashi Kokubun). Backport changed from 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED to 3.3: REQUIRED, 3.4: REQUIRED, 4.0: DONE ruby_4_0 commit:42c09041fe98a932d5a2a14da861527d2d80b807 merged revision(s) commit:0d7e50a1746bfa3db2a50478d3680cd7c36ea383. ---------------------------------------- Bug #22191: `Signal.trap(:EXIT)` exception only shown if `at_exit` also raises https://bugs.ruby-lang.org/issues/22191#change-118083 * Author: Earlopain (Earlopain _) * Status: Closed * ruby -v: ruby 4.1.0dev (2026-05-29T14:34:40Z master 7a07a54298) +PRISM [x86_64-linux] * Backport: 3.3: REQUIRED, 3.4: REQUIRED, 4.0: DONE ---------------------------------------- ```rb Signal.trap(:EXIT, proc { raise "foo" }) # No output ``` ```rb Signal.trap(:EXIT, proc { raise "foo" }) at_exit { raise "bar" } # test.rb:2:in 'block in <main>': bar (RuntimeError) # test.rb:1:in 'block in <main>': foo (RuntimeError) ``` A bit weird -- https://bugs.ruby-lang.org/
Issue #22191 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 3.3: REQUIRED, 3.4: REQUIRED, 4.0: DONE to 3.3: REQUIRED, 3.4: DONE, 4.0: DONE ruby_3_4 commit:e1bb38b7a6b8900e1eb8fbd37271a911b37729b5 merged revision(s) commit:0d7e50a1746bfa3db2a50478d3680cd7c36ea383. ---------------------------------------- Bug #22191: `Signal.trap(:EXIT)` exception only shown if `at_exit` also raises https://bugs.ruby-lang.org/issues/22191#change-118458 * Author: Earlopain (Earlopain _) * Status: Closed * ruby -v: ruby 4.1.0dev (2026-05-29T14:34:40Z master 7a07a54298) +PRISM [x86_64-linux] * Backport: 3.3: REQUIRED, 3.4: DONE, 4.0: DONE ---------------------------------------- ```rb Signal.trap(:EXIT, proc { raise "foo" }) # No output ``` ```rb Signal.trap(:EXIT, proc { raise "foo" }) at_exit { raise "bar" } # test.rb:2:in 'block in <main>': bar (RuntimeError) # test.rb:1:in 'block in <main>': foo (RuntimeError) ``` A bit weird -- https://bugs.ruby-lang.org/
participants (4)
-
Earlopain (Earlopain _) -
k0kubun (Takashi Kokubun) -
nagachika (Tomoyuki Chikanaga) -
nobu (Nobuyoshi Nakada)