Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
ghost opened this Issue · 3 comments

1 participant

@ghost

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.

@dbussink
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
@ghost

@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.

@dbussink
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
Something went wrong with that request. Please try again.