[#35027] [Ruby 1.9-Bug#4352][Open] [patch] Fix eval(s, b) backtrace; make eval(s, b) consistent with eval(s) — "James M. Lawrence" <redmine@...>

Bug #4352: [patch] Fix eval(s, b) backtrace; make eval(s, b) consistent with eval(s)

16 messages 2011/02/01

[#35114] [Ruby 1.9-Bug#4373][Open] http.rb:677: [BUG] Segmentation fault — Christian Fazzini <redmine@...>

Bug #4373: http.rb:677: [BUG] Segmentation fault

59 messages 2011/02/06

[#35171] [Ruby 1.9-Bug#4386][Open] encoding: directive does not affect regex expressions — mathew murphy <redmine@...>

Bug #4386: encoding: directive does not affect regex expressions

9 messages 2011/02/09

[#35237] [Ruby 1.9-Bug#4400][Open] nested at_exit hooks run in strange order — Suraj Kurapati <redmine@...>

Bug #4400: nested at_exit hooks run in strange order

12 messages 2011/02/15

[ruby-core:35071] Bug in system()?

From: Anthony Wright <anthony@...>
Date: 2011-02-03 13:57:52 UTC
List: ruby-core #35071
I've just hit a problem where the system() method to call an external program failed in a fairly unpredictable way, and I couldn't get any clues from within ruby to diagnose the problem. As a result I ended up debugging process.c to work out what the problem was.

My code looks something like:

system("/bin/tar --extract --directory=#{dir} --file=#{file}")

if $?.exitstatus != 0
     raise "tar unpack failed with exitstatus: #{$?.exitstatus}"
end

Unfortunately what I got back was:

NoMethodError: undefined method 'exitstatus' for nil:NilClass


The reason for this was that the system() called failed but didn't set '$?', so the if failed when it tried to look at the exitstatus.

The problem ultimately boiled down to the fork() system call failing with ENOMEM (badly configured system, but that's another matter).

Am I missing something here? Should there be a way to get errno from ruby, or am I missing other diagnostic information I could have used?

Is there a bug in system()? Shouldn't it always set '$?' ?

I suspect that if I did a successful system() call, and then a faulty system() call, '$?' would be left untouched by the faulty call, so either looking at $? isn't the correct way to check whether system() was successful, or this is a bug.

thanks,

Anthony Wright



In This Thread

Prev Next