Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Pathname#dup is broken in 1.7.5. #1209

Closed
mbj opened this Issue · 5 comments

4 participants

Markus Schirp Hiro Asari Charles Oliver Nutter Benoit Daloze
Markus Schirp
mbj commented

Today I tried to update some of my app to 1.7.5. But this bug had been introduced:

[mbj@mbj ~]$ java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
[mbj@mbj ~]$ ruby -v
jruby 1.7.5 (1.9.3p392) 2013-10-07 74e9291 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_25-b15 [linux-amd64]
[mbj@mbj ~]$ ruby -r pathname -e 'pathname = Pathname.new("foo"); p pathname.dup' 
<Pathname:null>
[mbj@mbj ~]$ ruby -r pathname -e 'pathname = Pathname.new("foo"); p pathname.dup.to_s' 
RubyPathname.java:306:in `to_s': java.lang.NullPointerException
        from RubyPathname$INVOKER$i$0$0$to_s.gen:-1:in `call'
        from CachingCallSite.java:306:in `cacheAndCall'
        from CachingCallSite.java:136:in `call'
        from -e:1:in `__file__'
        from -e:-1:in `load'
        from Ruby.java:814:in `runScript'
        from Ruby.java:807:in `runScript'
        from Ruby.java:676:in `runNormally'
        from Ruby.java:525:in `runFromMain'
        from Main.java:395:in `doRunFromMain'
        from Main.java:290:in `internalRun'
        from Main.java:217:in `run'
        from Main.java:197:in `main'
Hiro Asari
Owner

Confirmed on 1.7.8.

Charles Oliver Nutter
Owner

Ping @eregon.

Benoit Daloze
Collaborator

Typos ..., anyway fixed in a76ec1d. Sorry for the bug.

I am wondering though, why you want to #dup a Pathname. If we ignore instance variables, Pathname instances are supposed immutable.

Benoit Daloze eregon closed this
Markus Schirp

@eregon I use the adamantium library. Instance variables get deep frozen. Because calling #freeze causes side effects the adamantium #dups affected instances prior to freeze and assignment.

Benoit Daloze
Collaborator

I see, I think Pathname should always freeze itself in #initialize (or at least its internal path String), it might be worth opening an issue on bugs.ruby-lang.org. Semantics with "fake" immutable objects like Pathname are complicated. For instance, on MRI:

> p = Pathname("some/place")
> p2 = p.dup
> p.freeze
=> #<Pathname:some/place>
> p.frozen?
=> true
> p2.frozen?
=> false
> p.instance_variable_get("@path").frozen?
=> true
> p2.instance_variable_get("@path").frozen?
=> true

You might call that a bug.
Practically I guess it does not cause big problems since no one is supposed to ever touch the internal @path, nor modify the result of #to_s or #to_path.

Benoit Daloze eregon referenced this issue from a commit
Benoit Daloze eregon add test for Pathname#dup
* See #1209
3ca2a90
Benoit Daloze eregon referenced this issue from a commit
Benoit Daloze eregon add test for Pathname#dup
* See #1209
e95133f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.