Skip to content

Strange behaviour while spawning processes #161

@ranjanan

Description

@ranjanan

Consider the following file (example.jl) that I want to statically compile:

using Distributed
 using Distributions
 Base.@ccallable function julia_main(ARGS::Vector{String})::Cint
 
     @show isdefined(Main, :Distributed)
     @show isdefined(Main, :addprocs)
     function f(a)
         x = Normal(0,1)
         @show typeof(x)
     end
     myaddprocs(2)
     pmap(f, 1:2)
 
     return 0
 end
 function myaddprocs(n)
     println("In myaddprocs")
     @show isdefined(Main, :Distributed)
     @show isdefined(Main, :addprocs)
     @show isdefined(Distributed, :addprocs)
     Distributed.addprocs(n)
     @everywhere Core.eval(Main, :(using Distributions))
 end

Now suppose I do build_executable("example.jl"). When I do ./example, I'll get an error message about it not being able to spawn Julia processes (#84). I found a workaround to this here: #84 (comment). This basically copies over your julia binary file and then changes its rpath. So I followed this fix and got it to work.

However, when I do ]rm Distributions and try running the executable again, I get the following error:

isdefined(Main, :Distributed) = true
isdefined(Main, :addprocs) = true
In myaddprocs
isdefined(Main, :Distributed) = true
isdefined(Main, :addprocs) = false
isdefined(Distributed, :addprocs) = true
fatal: error thrown and no exception handler available.
Base.CompositeException(exceptions=Array{Any, (3,)}[
  Base.CapturedException(ex=Distributed.RemoteException(pid=2, captured=Base.CapturedException(ex=ArgumentError(msg="Package Distributions not found in current path:
- Run `import Pkg; Pkg.add("Distributions")` to install the Distributions package.

This kind of defeats the purpose of static compilation if the package isn't installed on my computer. I don't understand what changed between v0.6 and v1.0 to make this happen.

Here's my versioninfo():

julia> versioninfo()
Julia Version 1.0.2
Commit d789231e99 (2018-11-08 20:11 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, broadwell)

P.S. Secondary issue: It's kind of strange that addprocs went out of scope in a function that wasn't julia_main

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions