Skip to content
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

GzipReader#mtime gives the wrong time #1422

Closed
DavidEGrayson opened this issue Jan 20, 2014 · 8 comments
Closed

GzipReader#mtime gives the wrong time #1422

DavidEGrayson opened this issue Jan 20, 2014 · 8 comments
Milestone

Comments

@DavidEGrayson
Copy link
Contributor

GzipReader#mtime always just returns the timestamp of the time that the object was created instead of an actual modification time read from the GZip header.

Here is some example code that reproduces this issue:

require 'zlib'
require 'stringio'
io = StringIO.new "\x1f\x8b\x08\x00\x44\x33\x22\x11\x00\xff\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00"
r = Zlib::GzipReader.new(io)
puts "%x" % r.mtime

When I run this program with MRI 2.0.0, it correctly prints "11223344". When I run it with JRuby I get the current timestamp.

Here is shell output showing what version of JRuby I am running and the incorrect output:

$ jruby -v && jruby test.rb
jruby 1.7.10 (1.9.3p392) 2014-01-09 c4ecd6b on Java HotSpot(TM) 64-Bit Server VM 1.7.0_45-b18 [Windows 8-amd64]
52dc9f31

When I looked, I couldn't see any code in the GzipReader class that actually grabs the modification time from jzlib and stores it.

I would have simply fixed this and submitted a pull request, but jzlib also has a bug in it preventing it from reporting the modification time correctly. We need to wait for ymnk/jzlib#13 to be handled before I can fix JRuby.

DavidEGrayson added a commit to DavidEGrayson/jruby that referenced this issue Jan 20, 2014
@DavidEGrayson
Copy link
Contributor Author

I tested this again today with MRI 2.2.0-p0 and JRuby 9.0.0.0-pre1, and nothing has changed so the bug is still there.

@DavidEGrayson
Copy link
Contributor Author

I tested it again and this bug is still present in JRuby 9.0.0.0.

@enebo
Copy link
Member

enebo commented Feb 17, 2017

@DavidEGrayson it appears the jzlib issues has been resolved. Care you make a PR for this?

@DavidEGrayson
Copy link
Contributor Author

DavidEGrayson commented Apr 1, 2017

OK, I tried making a PR but I got stuck when I tried to upgrade jzlib to the latest version. They fixed their issue in commit ymnk/jzlib@1a5fb10 in January 2014 but they have not released a new version since 1.1.3 in October 2013. So I am not sure if pom.rb can fetch jzlib from GitHub or if there is a better way to upgrade it.

I notice that you seem to have a pure Ruby implementation of the Zlib stuff in lib/ruby/stdlib/ffi/platform/zlib.rb.ffi. Maybe you could switch to that instead of jzlib, or start maintaining your own fork of jzlib?

@DavidEGrayson
Copy link
Contributor Author

For what it's worth, you can see the work I did in this branch to add a test and fix the JRuby java code:

https://github.com/DavidEGrayson/jruby/tree/pr_zlib_mtime

@headius
Copy link
Member

headius commented May 25, 2023

This will be fixed with a jzlib update, now that we have taken over the library (https://github.com/jruby/jzlib). This is the underlying cause of rack/rack#2027, reported in JRuby as #7746.

@headius headius added this to the JRuby 9.4.3.0 milestone May 25, 2023
@DavidEGrayson
Copy link
Contributor Author

Cool. Feel free to cherry-pick my commit from 6 years ago working on this stuff and adding a test for it:

DavidEGrayson@f6b6f2c

@headius headius closed this as completed May 25, 2023
@headius
Copy link
Member

headius commented May 25, 2023

@DavidEGrayson Great! I will pick that commit to get the test.

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