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

workspace() and LastMain regression #17764

Closed
davidagold opened this issue Aug 2, 2016 · 4 comments
Closed

workspace() and LastMain regression #17764

davidagold opened this issue Aug 2, 2016 · 4 comments
Assignees
Labels
regression Regression in behavior compared to a previous version

Comments

@davidagold
Copy link
Contributor

@maleadt and I uncovered a regression in the workspace() behavior. Compare the behavior of calling the constructors of Foo and Bar after workspace():

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.0-rc0+110 (2016-08-01 16:59 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit e2d2925* (1 day old master)
|__/                   |  x86_64-apple-darwin15.5.0

julia> type Foo
          foo::Vector{Float32}
       end

julia> Foo([1.])
Foo(Float32[1.0])

julia> type Bar
          foo::String
       end

julia> Bar("bar")
Bar("bar")

julia> workspace()

julia> type Foo
          foo::Vector{Float32}
       end
WARNING: Method definition (::Type{Main.Foo})(Array{Float32, 1}) in module Main at REPL[1]:2 overwritten in module Main at REPL[7]:2.

julia> Foo([1.])
LastMain.Foo(Float32[1.0])

julia> type Bar
          foo::String
       end
WARNING: Method definition (::Type{Main.Bar})(String) in module Main at REPL[3]:2 overwritten in module Main at REPL[10]:2.

julia> Bar("bar")
Bar("bar")

However, on 0.4.6:

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.4.6 (2016-06-19 17:16 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-apple-darwin13.4.0

julia> type Foo
          foo::Vector{Float32}
       end

julia> Foo([1.])
Foo(Float32[1.0f0])

julia> type Bar
          foo::String
       end
WARNING: Base.String is deprecated, use AbstractString instead.
  likely near no file:0
WARNING: Base.String is deprecated, use AbstractString instead.
  likely near no file:0

julia> Bar("bar")
WARNING: Base.String is deprecated, use AbstractString instead.
  likely near no file:0
WARNING: Base.String is deprecated, use AbstractString instead.
  likely near no file:0
WARNING: Base.String is deprecated, use AbstractString instead.
  likely near no file:0
Bar("bar")

julia> workspace()

julia> type Foo
          foo::Vector{Float32}
       end

julia> Foo([1.])
Foo(Float32[1.0f0])

julia> type Bar
          foo::String
       end
WARNING: Base.String is deprecated, use AbstractString instead.
  likely near no file:0
WARNING: Base.String is deprecated, use AbstractString instead.
  likely near no file:0

julia> Bar("bar")
WARNING: Base.String is deprecated, use AbstractString instead.
  likely near no file:0
WARNING: Base.String is deprecated, use AbstractString instead.
  likely near no file:0
WARNING: Base.String is deprecated, use AbstractString instead.
  likely near no file:0
Bar("bar")

Also, on 0.5,

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.0-rc0+110 (2016-08-01 16:59 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit e2d2925* (1 day old master)
|__/                   |  x86_64-apple-darwin15.5.0

julia> type Foo end

julia> workspace()

julia> type Foo end
WARNING: Method definition (::Type{Main.Foo})() in module Main at REPL[1]:1 overwritten in module Main at REPL[3]:1.

julia> @which Foo()
LastMain.Foo() at REPL[3]:1

julia> typeof(Foo()) == Main.Foo
true

julia> typeof(Foo()) == LastMain.Foo
false
@maleadt
Copy link
Member

maleadt commented Aug 2, 2016

Bisected the first issue (ie. Foo resolving to LastMain) to #17405.

@kshyatt kshyatt added the regression Regression in behavior compared to a previous version label Aug 2, 2016
@JeffBezanson
Copy link
Member

This is probably due to this line in toplevel.c:

    if (old_main) // don't block continued loading of incremental caches
        jl_main_module->uuid = old_main->uuid;

Giving 2 modules the same uuid doesn't bode well for telling things apart. @vtjnash Can we live without this?

@vtjnash
Copy link
Member

vtjnash commented Aug 2, 2016

No, as the comment says, this line is critical for being able to use using after calling workspace. There's nothing wrong with modules having the same id or for object_ids to be non-unique. Why is printing failing?

@JeffBezanson
Copy link
Member

The type cache is equating two types that it shouldn't due to the object_id collision. While object_id necessarily has collisions since it might hash a large amount of data, it would be nice to avoid collisions this blatant. For now I'll see if I can make the type cache robust to this.

@JeffBezanson JeffBezanson self-assigned this Aug 2, 2016
JeffBezanson added a commit that referenced this issue Aug 2, 2016
In the type cache, make ordered comparison of types not depend on object_id.

Clarify help for `object_id`, since it technically can have collisions.

While I'm at it, remove unnecessary call to re-sort `tn->linearcache`
(it is not in sorted order).
JeffBezanson added a commit that referenced this issue Aug 3, 2016
In the type cache, make ordered comparison of types not depend on object_id.

Clarify help for `object_id`, since it technically can have collisions.

While I'm at it, remove unnecessary call to re-sort `tn->linearcache`
(it is not in sorted order).
JeffBezanson added a commit that referenced this issue Aug 3, 2016
fix #17764, type problem due to object_id collision after `workspace()`
mfasi pushed a commit to mfasi/julia that referenced this issue Sep 5, 2016
…orkspace()`

In the type cache, make ordered comparison of types not depend on object_id.

Clarify help for `object_id`, since it technically can have collisions.

While I'm at it, remove unnecessary call to re-sort `tn->linearcache`
(it is not in sorted order).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression Regression in behavior compared to a previous version
Projects
None yet
Development

No branches or pull requests

5 participants