Project

General

Profile

Bug #6794

x64 mingw: test_at(TestTime) failure

Added by h.shirosaki (Hiroshi Shirosaki) about 5 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Normal
Target version:
ruby -v:
ruby 2.0.0dev (2012-07-25 trunk 36538) [x64-mingw32]
[ruby-core:46776]

Description

x64 mingw has the following failure.

[ 5/65] TestTime#test_at = 0.00 s
1) Failure:
test_at(TestTime) [c:/Users/hiroshi/work/ruby/test/ruby/test_time.rb:194]:
<-146138510344> expected but was
.

I guess Time.at(large value) fails for the following reason.

Time.at calls FileTimeToSystemTime() in localtime_r().
https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L6565

Time limit is 0x8000000000000000 which is a little smaller than 8bytes(= time_t)(= long long).
http://msdn.microsoft.com/en-us/library/windows/desktop/ms724280(v=vs.85).aspx

Instead, using _localtime_64s() seems to work fine.
I changed to use _gmtime_64s() for consistency. I added declarations since mingw-w64 doesn't have these declaration.

I attached a patch.

Associated revisions

Revision 36556
Added by shirosaki almost 5 years ago

win32/win32.c: fix localtime_r() on x64-mingw

* win32/win32.c (gmtime_r): use _gmtime64_s() with x86_64-w64-mingw32.

* win32/win32.c (localtime_r): use _localtime64_s() with
x86_64-w64-mingw32. Since FileTimeToSystemTime() seems not work with
large value under x64. Mingw-w64 doesn't have these declaration.
[Bug #6794]

Revision 36556
Added by shirosaki almost 5 years ago

win32/win32.c: fix localtime_r() on x64-mingw

* win32/win32.c (gmtime_r): use _gmtime64_s() with x86_64-w64-mingw32.

* win32/win32.c (localtime_r): use _localtime64_s() with
x86_64-w64-mingw32. Since FileTimeToSystemTime() seems not work with
large value under x64. Mingw-w64 doesn't have these declaration.
[Bug #6794]

Revision 36556
Added by shirosaki almost 5 years ago

win32/win32.c: fix localtime_r() on x64-mingw

* win32/win32.c (gmtime_r): use _gmtime64_s() with x86_64-w64-mingw32.

* win32/win32.c (localtime_r): use _localtime64_s() with
x86_64-w64-mingw32. Since FileTimeToSystemTime() seems not work with
large value under x64. Mingw-w64 doesn't have these declaration.
[Bug #6794]

Revision 36556
Added by shirosaki almost 5 years ago

win32/win32.c: fix localtime_r() on x64-mingw

* win32/win32.c (gmtime_r): use _gmtime64_s() with x86_64-w64-mingw32.

* win32/win32.c (localtime_r): use _localtime64_s() with
x86_64-w64-mingw32. Since FileTimeToSystemTime() seems not work with
large value under x64. Mingw-w64 doesn't have these declaration.
[Bug #6794]

History

#1 [ruby-core:46780] Updated by h.shirosaki (Hiroshi Shirosaki) about 5 years ago

  • Subject changed from x86 mingw: test_at(TestTime) failure to x64 mingw: test_at(TestTime) failure

#2 [ruby-core:46821] Updated by luislavena (Luis Lavena) almost 5 years ago

  • Category set to core
  • Status changed from Open to Assigned
  • Assignee changed from luislavena (Luis Lavena) to nobu (Nobuyoshi Nakada)
  • Target version set to 2.0.0
  • % Done changed from 0 to 50

=begin
Thank you Hiroshi,

I can confirm patch works:

Finished tests in 0.085005s, 764.6609 tests/s, 7411.3287 assertions/s.
65 tests, 630 assertions, 0 failures, 0 errors, 0 skips

ruby -v: ruby 2.0.0dev (2012-07-27 trunk 36551) [x64-mingw32]

Reassigning to Nobu for final consideration.
=end

#3 [ruby-core:46822] Updated by nobu (Nobuyoshi Nakada) almost 5 years ago

Seems working fine.
Please check in.

BTW, 32bit mingw doesn't have 64s() family?

#4 Updated by Anonymous almost 5 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 50 to 100

This issue was solved with changeset r36556.
Hiroshi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


win32/win32.c: fix localtime_r() on x64-mingw

  • win32/win32.c (gmtime_r): use _gmtime64_s() with x86_64-w64-mingw32.

  • win32/win32.c (localtime_r): use _localtime64_s() with
    x86_64-w64-mingw32. Since FileTimeToSystemTime() seems not work with
    large value under x64. Mingw-w64 doesn't have these declaration.
    [Bug #6794]

#5 [ruby-core:46828] Updated by h.shirosaki (Hiroshi Shirosaki) almost 5 years ago

Thank you. Checked in.

BTW, 32bit mingw doesn't have 64s() family?

It seems that gcc 4.6.1 (tdm gcc 32bit) doesn't have _localtime64_s.

gcc 4.6.3 (rubenvb-4.6.3) i686-w64-mingw32 (32bit) has _localtime64_s.

The following page's example worked with rubenvb-4.6.3.
http://msdn.microsoft.com/en-us/library/a442x3ye(v=vs.80).aspx

Also available in: Atom PDF