1

Having an "interesting" segfault with a rake task. When run as quoted here from the command line, it works properly. If I run all rake tasks from a single system call, I get a segfault.

task :cruise do
  system 'rake db:reset db:test:clone teabag'
  system 'rake spec'
end

For those of you unfamiliar with it, Teabag is "a JavaScript test runner built on top of Rails". So what we have here is basically:

  1. Reinitialise the (development) database
  2. Clone the test database from the known-state development one; and
  3. Run specs for {Java,Coffee}Script and Ruby/Rails.

Version information:

  • OS X 10.8.2
  • ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin12.2.0]
  • Not using rvm
  • Rails 3.2.12

My Gemfile and Gemfile.lock are at this Gist. Task output, including crash dump, is on Pastebin.

EDITED 5 March 2013 12:20 SGT (GMT+8) *

I rewrote the task as

task :cruise do
  ['db:reset', 'db:test:clone', 'teabag', 'spec'].each do |task|
    Rake::Task[task].reenable
    Rake::Task[task].invoke
  end
end

and it runs as expected. (Note that I had to add Rake::Task[task].reenable to eliminate the RSpec segfault).

This still doesn't answer why RSpec will reliably segfault when either run as part of a multi-task rake command line (as with the original system-calling task) or when run in the reworked cruise task without calling reenable before invoke. But I've got the workaround, so I consider the question answered.

Jeff Dickey
  • 1,071
  • 11
  • 21
  • You should not use `system` to invoke a rake task from within another rake task. Use `Rake::Task['namespace:task'].invoke` instead. See this for more info http://stackoverflow.com/a/1290119/100466. See if that fixes the problem. – Waseem Mar 04 '13 at 09:37
  • Thanks, @waseem. You got me to where I needed to be, and I updated the main question text accordingly. – Jeff Dickey Mar 05 '13 at 04:27

0 Answers0