Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Very obscure issue with Ctrl + C in console not workng and periodic freezes

#6760

There's a good chance this is a Ruby bug with the way it deals with process management, but I'm posting it here because Rails is the only place it affects me. Now I know the issue, I can work round it, but it's something caused me a hell of a lot of frustration trying to track this down.

I had issues with Ctrl + C not working in "rails console" (it wasn't working), and occasionally I found "reload!" and some methods freezing up Ruby. (I had to use kill -9 to terminate things, a normal 'kill' didn't work. I went down alsorts of paths looking at gems, etc. After several hours I realised the issue went away if I booted into Maverick's kernel (2.6.35) instead the natty kernel (2.6.38). After more fiddling I also found that changing my database.yml also got round the issue. It turns out the call to hostname in some ERB in my database.yml was the cause after 3-4 hours of hair pulling!

I'm running Ruby trunk, Rails 3.0.7, and Ubuntu Natty.

To replicate the issue:

On natty and Rails 3.x, create a new project 'rails new tester'. Edit config/database.yml and put echo in config/application.rb, then run "rails console". Try and press Ctrl + C once loaded, it probably won't do anything. Loading irb normally and pressing Ctrl + C will work fine.

While the loack of Ctrl + C is merely an annoyance, I find that if you use backticks in code that runs after "reload!" is called, or use backticks a lot in general, the console seems to lock up very randomly and that kill -9 is needed. This doesn't happen if I revert back to Maverick kernel, 2.6.35.

As a result, I guess this is a corner case shell-spawning/process/threading issue in Ruby itself, and not Rails. However I only seem to replicate this is Rails for now, hence reporting. It seems the Dependency system in ActiveSupport is what triggers this, as I can't replicate this in irb.

I'm guessing some other people will have report process/threading issues like what I've mentioned above but obviously manifest very differently depending on how their code utilises backticks.

Hopefully someone smarter than me will be see what is happening and will be able to pass this upstream to the Ruby devs, explaining to them a way to replicate it without Rails so it can be fixed.

When my console instance locks up, if I attach strace to it I get a constant loop of:

sched_yield() = 0

Reported by VirtualFunction · May 1st, 2011 @ 02:42 AM

State: new
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Daniel Choi
    Daniel Choi

    I have the same issue after I upgraded to Ubuntu 11.04. I tried reinstalling ruby 1.9.2 via RVM but that didn't fix the problem.

    May 4th, 2011 @ 05:46 PM

  2. Daniel Choi
    Daniel Choi

    There's a similar ticket filed for Ruby 1.9.2

    http://redmine.ruby-lang.org/issues/4608

    May 4th, 2011 @ 05:48 PM

  3. Daniele Orlandi
    Daniele Orlandi

    Suspending the process with CTRL-Z and putting it on foreground again breaks the lock.

    May 9th, 2011 @ 03:42 PM

  4. VirtualFunction
    VirtualFunction

    Yes, I noticed that too. However it doesn't stop the crashes, which I believe to be related. I've found that the more recent Natty Kernel and SVN trunk of Ruby seems to have stopped the issue for now (I'll need to check to see which fixed it). I'm hoping it's fixed.

    May 9th, 2011 @ 04:49 PM