Issue #17849 has been updated by Eregon (Benoit Daloze).


I think (2) is rare, and IMHO such programs should be fixed.
What would happen is then those programs can't be interrupted (only by kill=
ing the process), but then that also becomes a clear motivation to fix thos=
e programs so they can be interrutped safely.

Not sure about (1), I think it's loading the current thread + saving curren=
t value of the mask, writing the interrupt mask for every `ensure`, and res=
toring it once the `ensure` finishes.
It needs to be done on the non-exceptional path too, so indeed it could be =
some overhead.
I think we need to measure it in practice here to evaluate better the overh=
ead.

The whole strategy here relies on code in `ensure` having code that only ta=
kes a small amount of time.
If that doesn't hold, it will either hang (motivating those programs to be =
fixed),
or we could resort to the old semantics after some extra time (e.g., 10s), =
similar to what https://bugs.ruby-lang.org/issues/17849#note-3 proposes, an=
d then print a big warning that the program misbehaved (and that state migh=
t be corrupted due to that as `ensure` likely has been interrupted).
That could be useful notably for Ctrl+C to still work as it does currently =
in such situations.

----------------------------------------
Feature #17849: Fix Timeout.timeout so that it can be used in threaded Web =
servers
https://bugs.ruby-lang.org/issues/17849#change-92040

* Author: duerst (Martin D=FCrst)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
Making this a separate issue from #17837

Eregon (Benoit Daloze) wrote in https://bugs.ruby-lang.org/issues/17837#not=
e-10 (which is  about timeouts for regular expressions):

> I think fixing Timeout.timeout might be possible.
> The main/major issue is it can trigger within `ensure`, right? Is there a=
nything else?
> We could automatically mask `Thread#raise` within `ensure` so it only hap=
pens after the `ensure` body completes.
> And we could still have a larger "hard timeout" if an `ensure` takes way =
too long (shouldn't happen, but one cannot be sure).
> I recall discussing this with @schneems some time ago on Twitter.





-- =

https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=3Dunsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>