JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-4149

[windows] JRuby reports wrong file sizes when native support is enabled

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.4.0RC2
    • Fix Version/s: JRuby 1.5
    • Component/s: Windows
    • Labels:
      None
    • Number of attachments :
      0

      Description

      1.

      jruby -J-Djruby.native.enabled=true  -e "t = File.new('blah', 'w+'); t << '123'; t.flush; p t.stat.size; p File.size('blah')"
      0
      3
      

      MRI returns always 3. JRuby with native disabled also returns correctly 3 and 3.

      2.

      Also, similar issues reported for Tempfile:

      D:\work\jruby-dev>jruby -J-Djruby.native.enabled=true -rtempfile -e "t = Tempfile.new('blah'); t << '123'; p t.length; p t.size; p  t.stat.size"
      0
      0
      0
      

      MRI returns 3 always. JRuby with native disabled also return 3 always.

        Issue Links

          Activity

          Hide
          Vladimir Sizikov added a comment -

          Wayne provided a suggested fix during IRC conversation: https://gist.github.com/2d40abb90a36f43fbd8d

          This, with appropriate RufyFile.stat() adjustment, fixes the size issue. BUT, it will create more issues, since closing the C RT descriptor automatically closes the main file descriptor as well. Not closing the C RT descriptor is also not an opiton - this would leak open descriptors.

          See JRUBY-4152 for descriptor leakage.

          Show
          Vladimir Sizikov added a comment - Wayne provided a suggested fix during IRC conversation: https://gist.github.com/2d40abb90a36f43fbd8d This, with appropriate RufyFile.stat() adjustment, fixes the size issue. BUT , it will create more issues, since closing the C RT descriptor automatically closes the main file descriptor as well. Not closing the C RT descriptor is also not an opiton - this would leak open descriptors. See JRUBY-4152 for descriptor leakage.
          Hide
          Vladimir Sizikov added a comment -

          Marking for 1.4, since reporting wrong file size for open files is, well, bad.

          Show
          Vladimir Sizikov added a comment - Marking for 1.4, since reporting wrong file size for open files is, well, bad.
          Hide
          Vladimir Sizikov added a comment -

          Applied the minimal/simplest workaround in 5192c02 on master branch. The size is now being reported correctly on Windows, new regression tests verify that, and all 3 use cases listed above now work too. No change in jnr/jna needed for this.

          Show
          Vladimir Sizikov added a comment - Applied the minimal/simplest workaround in 5192c02 on master branch. The size is now being reported correctly on Windows, new regression tests verify that, and all 3 use cases listed above now work too. No change in jnr/jna needed for this.
          Hide
          Thomas E Enebo added a comment -

          Workaround has been applied for 1.4 and in master, but real solution is being worked on. Marking for 1.5.

          Show
          Thomas E Enebo added a comment - Workaround has been applied for 1.4 and in master, but real solution is being worked on. Marking for 1.5.
          Hide
          Charles Oliver Nutter added a comment -

          Marking as fixed, since it has been "fixed" sufficiently for the bug report. If there's more work needed, open a new bug.

          Show
          Charles Oliver Nutter added a comment - Marking as fixed, since it has been "fixed" sufficiently for the bug report. If there's more work needed, open a new bug.

            People

            • Assignee:
              Vladimir Sizikov
              Reporter:
              Vladimir Sizikov
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: