8000 `Date::Error` with `Date.parse` and JRuby 10 · Issue #8782 · jruby/jruby · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Date::Error with Date.parse and JRuby 10 #8782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ankane opened this issue Apr 20, 2025 · 3 comments
Open

Date::Error with Date.parse and JRuby 10 #8782

ankane opened this issue Apr 20, 2025 · 3 comments

Comments

@ankane
Copy link
ankane commented Apr 20, 2025

Hi, the following code throws a Date::Error: Invalid date after around 80 iterations on my machine with JRuby 10 (and no error with 9.4.12.0 or CRuby).

require "date"

1000.times do
  p Date.parse("01-Jan-1995")
end

Environment Information

  • jruby 10.0.0.0 (3.4.2) 2025-04-13 6ed59bc OpenJDK 64-Bit Server VM 21.0.6 on 21.0.6 +indy +jit [arm64-darwin]
  • macOS 15.4.1 arm64

Expected Behavior

No error

Actual Behavior

Date::Error: invalid date
  new_by_frags at /Users/andrew/.rbenv/versions/jruby-10.0.0.0/lib/ruby/stdlib/date.rb:450
         parse at /Users/andrew/.rbenv/versions/jruby-10.0.0.0/lib/ruby/stdlib/date.rb:492
@ankane
Copy link
Author
ankane commented Apr 22, 2025

Tried disabling JIT and the error goes away, fwiw.

@headius
Copy link
Member
headius commented Apr 23, 2025

Good catch! Must be some slight variation in the JIT logic for Date parsing.

@headius headius added this to the JRuby 10.0.1.0 milestone Apr 23, 2025
@enebo
Copy link
Member
enebo commented Apr 24, 2025

Just briefly looked at this. It appears like JIT is reusing a hash instance:

    return _parse_impl(str, :_comp => comp)

If in Java impl of _parse_impl I dup the second argument (the hash) then this runs to completion. What seems to be happening is that the same instance of the hash is being used and the parse mutates the hash given so next call will end up with an empty hash. I cannot seem to reproduce this outside of this exact case but I didn't spend much time on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0