Project

General

Profile

Bug #1735

Ruby compiled with gcc 4.4.0: problems in date.rb

Added by be9 (Oleg Dashevskii) about 10 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
ruby -v:
ruby 1.8.6 (2009-06-08 patchlevel 369) [x86_64-linux]
[ruby-core:24161]

Description

=begin
I have a 64-bit ArchLinux system with gcc 4.4.0 and glibc 2.10.1. The distro itself ships 1.8.7, but I use REE which is 1.8.6-based. I'll illustrate the problem with stock Ruby 1.8.6-p369.

===========================================
home:~% /opt/ruby-1.8.6-p369/bin/irb
irb(main):001:0> t = Time.now
=> Mon Jul 06 13:21:20 +0700 2009
irb(main):002:0> [t.year, t.month, t.day]
=> [2009, 7, 6]
irb(main):003:0> d = Date.civil_to_jd(t.year, t.month, t.day)
=> 248077102
irb(main):004:0> Date.jd_to_civil(d)
=> [2075, -1, 37364]
irb(main):005:0>
===========================================

I've run into this in my Rails app, namely with activesupport: 1.day.from_now and 1.year.from_now. The former raises ArgumentError with "invalid date", the latter just hangs.

The original post is on the REE group: http://groups.google.com/group/emm-ruby/browse_thread/thread/5bdb6869ed0f9843
Other people with gcc 4.4.0 have confirmed this bug.

Here's valid behavior in 1.8.7:

===========================================

RUBY_VERSION
=> "1.8.7"
RUBY_PATCHLEVEL
=> 173
t = Time.now
=> Mon Jul 06 13:34:12 0700 2009
[t.year, t.month, t.day]
=> [2009, 7, 6]
d = Date.civil_to_jd(t.year, t.month, t.day)
=> 2455019
Date.jd_to_civil(d)
=> [2009, 7, 6]
===========================================
=end

History

#1

Updated by tadf (tadayoshi funaba) about 10 years ago

=begin
type ruby -e 'p 1867216.25'.
and try to re-build ruby without optimization.

=end

#2

Updated by phinze (Paul Hinze) about 10 years ago

=begin
Same issue here on fresh install of ArchLinux with gcc 4.4.1:

$ ruby -e 'p 1867216.25'
186721625.0

As per tadayoshi funaba's suggestion, I rebuilt ruby-1.8.6-p286 after editing the root Makefile like so:

  • CFLAGS = -g -O2 -DRUBY_EXPORT -D_GNU_SOURCE=1
  • CFLAGS = -g -DRUBY_EXPORT -D_GNU_SOURCE=1

And that solved the problem for me, at least in date.rb. I'm a little worried about what optimization bugs might be lurking elsewhere.

So is there something we should be doing to prevent this from happening to other users? I'm not very familiar with Ruby's C source but I'm willing to dive in if someone points me in the right direction.
=end

#3

Updated by nlugovoi (Nikolai Lugovoi) almost 10 years ago

=begin
need to backport r23353 from branches/ruby_1_8 to 1.8.7 and 1.8.6
=end

#4

Updated by shyouhei (Shyouhei Urabe) almost 10 years ago

  • Assignee set to wyhaines (Kirk Haines)

=begin
Revision r25801 backports this into 1.8.7.
=end

#5

Updated by wyhaines (Kirk Haines) about 9 years ago

  • Status changed from Open to Closed

=begin
This was fixed with the r28153, which also resolved Backport #2392 [ruby-core:26868]. The r25801 referenced in this ticket was already applied in r25871. My tests for this bug are passing, so I am closing the ticket.
=end

Also available in: Atom PDF