Skip to content

Conversation

@m-j-w
Copy link
Contributor

@m-j-w m-j-w commented Mar 29, 2017

It appears in #20486, Base.Parallel has been renamed to Base.Distributed, but is
still exported. Thus, the export in base/exports.jl is not valid anymore. In
particular, when doing e.g. a [ s for s in names(Base) if typeof(getfield(Base,s))<:Function] an UndefVarError is thrown on 'Parallel'.

julia> [ s for s in names(Base) if typeof(getfield(Base,s))<:Function]
ERROR: UndefVarError: Parallel not defined
Stacktrace:
 [1] advance_filter(::##6#8, ::Array{Symbol,1}, ::Tuple{Bool,Symbol,Int64}) at ./iterators.jl:270
 [2] next at ./generator.jl:44 [inlined]
 [3] grow_to!(::Array{Symbol,1}, ::Base.Generator{Base.Iterators.Filter{##6#8,Array{Symbol,1}},##5#7}, ::Tuple{Bool,Symbol,Int64}) at ./array.jl:475
 [4] grow_to!(::Array{Union{},1}, ::Base.Generator{Base.Iterators.Filter{##6#8,Array{Symbol,1}},##5#7}, ::Tuple{Bool,Symbol,Int64}) at ./array.jl:483
 [5] grow_to!(::Array{Symbol,1}, ::Base.Generator{Base.Iterators.Filter{##6#8,Array{Symbol,1}},##5#7}) at ./array.jl:468
 [6] collect(::Base.Generator{Base.Iterators.Filter{##6#8,Array{Symbol,1}},##5#7}) at ./array.jl:412

@m-j-w m-j-w changed the title Remove Base.Parallel export. Remove Base.Parallel from being exported in 'base/exports.jl' Mar 29, 2017
@tkelman
Copy link
Contributor

tkelman commented Mar 29, 2017

If we've gone several weeks without this breaking anything, do we even need to export the new Distributed module name?

@m-j-w
Copy link
Contributor Author

m-j-w commented Mar 29, 2017

It also appears there are more symbols being exported but undefined in Base:

julia> for m in Base.Docs.modules
         for s in names(m)
            try
               getfield(m,s)
            catch e
               println("Module: $(m).$(string(s)) gives ", e)
            end
          end
       end

gives

Module: Base.Filesystem.JL_O_RANDOM gives UndefVarError(:JL_O_RANDOM)
Module: Base.Filesystem.JL_O_SEQUENTIAL gives UndefVarError(:JL_O_SEQUENTIAL)
Module: Base.Filesystem.JL_O_SHORT_LIVED gives UndefVarError(:JL_O_SHORT_LIVED)
Module: Base.Filesystem.JL_O_TEMPORARY gives UndefVarError(:JL_O_TEMPORARY)
Module: Base.MPFR.big_str gives UndefVarError(:big_str)
Module: Base.dSFMT.win32_SystemFunction036! gives UndefVarError(:win32_SystemFunction036!)
Module: Base.SparseArrays.dense gives UndefVarError(:dense)

I didn't check them more closely, yet. But from a quick look seems they are all exported but not actually defined.

Maybe an automated test for undefined exports would be helpful.

I could take a look later and update the PR.

@StefanKarpinski
Copy link
Member

Maybe an automated test for undefined exports would be helpful.

Yes, we definitely should have this. It seems like it might be good for an export that's undefined by the time a module is closed would be sensible. @JeffBezanson: is there a use case for undefined exports that's the reason we don't error or warn in that situation?

@ViralBShah
Copy link
Member

Cc @amitmurthy

@amitmurthy
Copy link
Contributor

If we've gone several weeks without this breaking anything, do we even need to export the new Distributed module name?

Let's keep the Distributed module name export for now. We should remove the import and re-exports of distributed API from Base in the next iteration when an explicit using Distributed will be required.

@m-j-w
Copy link
Contributor Author

m-j-w commented Mar 29, 2017

I've updated the PR to fix the missing exports (and changed the title accordingly):

  • module Parallel has been renamed to Distributed --> export renamed.
  • big_str is not defined in mpfr.jl, but rather in int.jl as macro @big_str --> removed export.
  • win32_SystemFunction036! is only available on windows --> conditionally exported.
  • dense is not defined in module SparseArray --> removed export.
  • JL_O_RANDOM etc. are never defined or used in module FileSystem --> removed export.

Locally, I've got now no erroneous exports anymore.
Please check.

@m-j-w m-j-w changed the title Remove Base.Parallel from being exported in 'base/exports.jl' Fix exports of undefined/missing/conditionally defined symbols (RFC/WIP) Mar 29, 2017
JL_O_TEMPORARY,
JL_O_SHORT_LIVED,
JL_O_SEQUENTIAL,
JL_O_RANDOM,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are likely platform dependent, see src/file_constants.h

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When grep-ing for those, I don't see them ever being used in a context of the Julia runtime. Only in that header file. What to do ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep them.

@m-j-w
Copy link
Contributor Author

m-j-w commented Mar 29, 2017

With the builds failing on Appveyor, it's clear that the 'random' export didn't work as intended, and that the JL_O_* indeed are platform dependent (also found them in mingw provided fcntl.h, but only there).
I'll try to get my Windows build environment up again to test locally first.

m-j-w added 3 commits March 31, 2017 21:45
It appears `Base.Parallel` has been renamed to `Base.Distributed`, but is
still exported.  Thus, the export in base/exports.jl is not valid anymore.  In
particular, when doing e.g. a `[ s for s in names(Base) if
typeof(getfield(Base,s))<:Function]` an UnDefVar error is thrown on 'Parallel'.

```jl
julia> [ s for s in names(Base) if typeof(getfield(Base,s))<:Function]
ERROR: UndefVarError: Parallel not defined
Stacktrace:
 [1] advance_filter(::#JuliaLang#6#8, ::Array{Symbol,1}, ::Tuple{Bool,Symbol,Int64}) at ./iterators.jl:270
 [2] next at ./generator.jl:44 [inlined]
 [3] grow_to!(::Array{Symbol,1}, ::Base.Generator{Base.Iterators.Filter{#JuliaLang#6#8,Array{Symbol,1}},#JuliaLang#5#7}, ::Tuple{Bool,Symbol,Int64}) at ./array.jl:475
 [4] grow_to!(::Array{Union{},1}, ::Base.Generator{Base.Iterators.Filter{#JuliaLang#6#8,Array{Symbol,1}},#JuliaLang#5#7}, ::Tuple{Bool,Symbol,Int64}) at ./array.jl:483
 [5] grow_to!(::Array{Symbol,1}, ::Base.Generator{Base.Iterators.Filter{#JuliaLang#6#8,Array{Symbol,1}},#JuliaLang#5#7}) at ./array.jl:468
 [6] collect(::Base.Generator{Base.Iterators.Filter{#JuliaLang#6#8,Array{Symbol,1}},#JuliaLang#5#7}) at ./array.jl:412
```
'big_str' is defined in 'int.jl' as macro, and exported in 'exports.jl' as '@big_str'
'dense' is exported but actually never defined anywhere in module 'SparseArray'.
@m-j-w m-j-w force-pushed the ParallelExports branch from 53333d3 to 9f8c429 Compare March 31, 2017 19:52
@m-j-w
Copy link
Contributor Author

m-j-w commented Mar 31, 2017

Filesystem and random number generator are a bit tricky since I didn't get Julia's dependencies to compile correctly on Windows. Thus, I removed those failing conditional exports for now from the PR.

  • module Parallel has been renamed to Distributed --> export renamed.
  • big_str is not defined in mpfr.jl, but rather in int.jl as macro @big_str --> removed export.
  • dense is not defined in module SparseArray --> removed export.

The following conditionally required exports (Windows only) are not adressed anymore:

  • win32_SystemFunction036! is only available on windows --> kept for now..
  • JL_O_RANDOM , JL_O_SHORT_LIVED etc. are only available on Windows --> kept for now.

I believe this now to be correct and the tests pass.

@amitmurthy
Copy link
Contributor

Is this still a RFC/WIP or is it done?

@m-j-w
Copy link
Contributor Author

m-j-w commented Apr 4, 2017

Should be done.

@m-j-w m-j-w changed the title Fix exports of undefined/missing/conditionally defined symbols (RFC/WIP) Fix exports of undefined/missing/conditionally defined symbols Apr 4, 2017
@amitmurthy amitmurthy merged commit e796e39 into JuliaLang:master Apr 4, 2017
@amitmurthy
Copy link
Contributor

Thanks.

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

Successfully merging this pull request may close these issues.

6 participants