Project

General

Profile

Actions

Bug #17164

closed

Threads can ignore kill/interrupt/abort

Added by spraints (Matt Burke) 7 months ago. Updated 25 days ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:99985]

Description

Threads can opt-out of requests to shut down the thread, including 'thr.kill' and the interrupt that happens when a main thread shuts down. When the interrupt happens, 'ensure' clauses will run in the thread's stack. If one of these clauses raises an error, a higher stack frame can rescue it and then execution proceeds as normal.

My understanding is that, when the main thread exits, all other threads are supposed to exit and then the program will exit. Using this 'ensure-raise-rescue' technique, a thread can delay program shutdown indefinitely.

The attached script reproduces the problem. It is very hard to exit without using 'kill -9'.


Files

neverexit.rb (422 Bytes) neverexit.rb spraints (Matt Burke), 09/10/2020 07:52 PM

Related issues

Is duplicate of Ruby master - Bug #13882: Exception in `ensure` stops threads from exitingClosedko1 (Koichi Sasada)Actions
Actions #1

Updated by jeremyevans0 (Jeremy Evans) 7 months ago

  • Is duplicate of Bug #13882: Exception in `ensure` stops threads from exiting added

Updated by matz (Yukihiro Matsumoto) 25 days ago

  • Status changed from Open to Closed

If the programmer intentionally ignores the interrupt, it is, by definition, intentional.
So I vote for leaving this as it is now.

Matz.

Actions

Also available in: Atom PDF