Timeout.timeout(…) fails to interrupt some code. #2287

Closed
ghost opened this Issue Apr 17, 2013 · 3 comments

Projects

None yet

1 participant

@ghost
ghost commented Apr 17, 2013

Code in question:

require 'timeout'
Timeout.timeout(3) do
  " " * (32**7)
end

Result:
Hangs for a long time & never raises Timeout::Error. ^C doesn't interrupt. Behavior is the same on MRI, so maybe it isn't worth it /too difficult to fix.

Owner

The problem is that this is code running inside the VM that takes a very long time. There isn't really any way to interrupt this. Curious as to where this comes from? It just gobbles up a large amount of memory on my system.

@dbussink dbussink closed this Apr 17, 2013
@ghost
ghost commented Apr 17, 2013

@dbussink It comes from malicious code that is eval'ed by an IRC bot. I worked around it by forking a subprocess, and wrapping Process.wait in Timeout.timeout instead. Good to know this, though.

Owner

You can probably do similar things with Bignum by starting a huge computation etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment