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

Pathname#dup is broken in 1.7.5. #1209

Closed
mbj opened this issue Nov 8, 2013 · 5 comments
Closed

Pathname#dup is broken in 1.7.5. #1209

mbj opened this issue Nov 8, 2013 · 5 comments
Labels
Milestone

Comments

@mbj
Copy link

@mbj mbj commented Nov 8, 2013

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'
@BanzaiMan
Copy link
Member

@BanzaiMan BanzaiMan commented Nov 21, 2013

Confirmed on 1.7.8.

@headius
Copy link
Member

@headius headius commented Nov 21, 2013

Ping @eregon.

eregon added a commit that referenced this issue Nov 21, 2013
* closes GH #1209
@eregon
Copy link
Member

@eregon eregon commented Nov 21, 2013

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.

@eregon eregon closed this Nov 21, 2013
@mbj
Copy link
Author

@mbj mbj commented Nov 21, 2013

@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.

eregon added a commit that referenced this issue Nov 21, 2013
* Fixes #1209.
@eregon
Copy link
Member

@eregon eregon commented Nov 21, 2013

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.

eregon added a commit that referenced this issue Nov 21, 2013
* See #1209
eregon added a commit that referenced this issue Nov 21, 2013
* See #1209
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants