Project

General

Profile

ActionsLike0

Bug #6571

closed

Time.mktime Y2K38 problem on 1.9.3p125 i386-mingw32

Added by MartinBosslet (Martin Bosslet) over 12 years ago. Updated over 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3p125 (2012-02-16) [i386-mingw32]
Backport:
[ruby-core:45552]

Description

=begin
This came up in https://bugs.ruby-lang.org/issues/6122.

(({Time.mktime(2038, 1, 19, 11, 14, 8)})) failed. To my understanding, 32 bit Time
issues shouldn't occur in 1.9.3? I'm assigning this to Luis, maybe he knows
about this and what to do? Please feel free to reassign back to me.
=end


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #6122: OpenSSL::PKCS7 verifyClosedMartinBosslet (Martin Bosslet)03/07/2012Actions

Updated by nobu (Nobuyoshi Nakada) over 12 years ago

  • Description updated (diff)
  • Status changed from Assigned to Feedback
  • Target version changed from 2.0.0 to 1.9.3

I can't reproduce it with 1.9.3p216, in JST and PST.
What are the failure message and your timezone?

Updated by akr (Akira Tanaka) over 12 years ago

2012/6/11 MartinBosslet (Martin Bosslet) :

Time.mktime(2038, 1, 19, 11, 14, 8) failed. To my understanding, 32 bit Time
issues shouldn't occur in 1.9.3? I'm assigning this to Luis, maybe he knows
about this and what to do? Please feel free to reassign back to me.

I couldn't reproduce the problem on GNU/Linux (x86_64 and i686).

% ./ruby -ve 'Time.mktime(2038, 1, 19, 11, 14, 8)'
ruby 2.0.0dev (2012-06-11 trunk 36028) [x86_64-linux]

% ./ruby -ve 'Time.mktime(2038, 1, 19, 11, 14, 8)'
ruby 2.0.0dev (2012-06-11 trunk 36030) [i686-linux]

So it seems platform dependent issue.

However I think you should show the actual result (failure message) and
your timezone, though.

Note that my timzone is +0900 (JST).

Tanaka Akira

Updated by phasis68 (Heesob Park) over 12 years ago

I guess it is not an issue of Time#mktime but an issue of OpenSSL.
Furthermore, the description is inaccurate.

Here is my test with ruby 1.9.3p194 (2012-04-20) [i386-mingw32]
C:\Ruby193\bin>irb
irb(main):001:0> require 'OpenSSL'
=> true
irb(main):002:0> cert = OpenSSL::X509::Certificate.new
=> #<OpenSSL::X509::Certificate subject=, issuer=, serial=0, not_before=nil, not_after=nil>
irb(main):003:0> cert.not_after = Time.mktime(2038, 1, 19, 12, 14, 7)
=> 2038-01-19 12:14:07 +0900
irb(main):004:0> cert.not_after = Time.mktime(2038, 1, 19, 12, 14, 8)
RangeError: bignum too big to convert into long' from (irb):4:in not_after='
from (irb):4
from C:/Ruby193/bin/irb:12:in `'

I think that this error due to time_to_time_t function defined in ext/openssl/ossl_asn1.c

time_t
time_to_time_t(VALUE time)
{
return (time_t)NUM2LONG(rb_Integer(time));
}

Updated by MartinBosslet (Martin Bosslet) over 12 years ago

  • Category changed from core to ext

Thanks for your analysis, guys. Makes sense now, why I couldn't reproduce it on 64 bits. The original #6122 did not contain the actual error that was raised, so thanks Heesob for pointing me towards the solution!

Updated by mghomn (Justin Peal) about 12 years ago

Great thanks to all of you.

Like0Actions #9

Updated by Anonymous over 8 years ago

  • Status changed from Assigned to Closed

Applied in changeset r55219.


openssl: use NUM2TIMET() to convert Integer to time_t

  • ext/openssl/ossl_asn1.c (time_to_time_t): Use NUM2TIMET() instead of
    NUM2LONG(). time_t may be larger than long.
    [ruby-core:45552] [Bug #6571]
ActionsLike0

Also available in: Atom PDF