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

PyCall master trips LLVM assertion on precompile #269

Open
staticfloat opened this issue May 13, 2016 · 23 comments
Open

PyCall master trips LLVM assertion on precompile #269

staticfloat opened this issue May 13, 2016 · 23 comments

Comments

@staticfloat
Copy link
Contributor

staticfloat commented May 13, 2016

Using the Homebrew build of Julia, which has LLVM assertions enabled by default, we get:

julia> using PyCall
INFO: Precompiling module PyCall...
Assertion failed: (ctx->gensym_assigned.at(idx)), function emit_expr, file codegen.cpp, line 3155.

signal (6): Abort trap: 6
__pthread_kill at /usr/lib/system/libsystem_kernel.dylib (unknown line)
ERROR: Failed to precompile PyCall to /Users/sabae/.julia/lib/v0.4/PyCall.ji
 in error at /usr/local/Cellar/julia/0.4.5/lib/julia/sys.dylib
 in compilecache at loading.jl:400
 in require at /usr/local/Cellar/julia/0.4.5/lib/julia/sys.dylib
@stevengj
Copy link
Member

Related to #254?

Maybe this is related to my use of global const foo = ... in the init, which I should really change to Refs or similar?

@zaburo-ch
Copy link

I'm finding this problem too.
I used homebrew build julia 0.4.5 on Mac OSX 10.11.2.

@zaburo-ch
Copy link

something wrong in the homebrew build of julia.
I tried to build myself, and successfully build PyCall.

git clone git://github.com/JuliaLang/julia.git
cd julia
git checkout release-0.4
make -j (num threads)

@stevengj
Copy link
Member

@zaburo-ch, good to know; I wonder what is wrong with Homebrew?

@zaburo-ch
Copy link

@stevengj sorry... I couldn't find what is wrong.
julia 0.4.6-pre was installed by that way. So there could possibly be problem in 0.4.5

@staticfloat
Copy link
Contributor Author

It's not something wrong with the Homebrew build, it's that Homebrew LLVM
has assertions enabled, whereas julia-built LLVM does not.

On Wed, May 18, 2016, 08:03 Kaizaburo Chubachi [email protected]
wrote:

@stevengj https://github.com/stevengj sorry... I couldn't find what is
wrong.
julia 0.4.6-pre was installed by that way. So there could possibly be
problem in 0.4.5


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#269 (comment)

-E

@stevengj
Copy link
Member

@staticfloat, thanks for the clarification. So there is a Julia problem that is being hidden by the lack of assertions? Or is there an incorrect assertion somewhere?

@staticfloat
Copy link
Contributor Author

I think there are many julia problems hidden by the lack of assertions. Pkg.test("Nettle") also fails when assertions are enabled; although both Nettle and PyCall have global const values, so perhaps these problems are all symptoms of that root issue.

@oschulz
Copy link

oschulz commented May 20, 2016

I see this too, with a self-compiled Julia-0.4.5 on Ubuntu-14.04 (built with override LLVM_VER=3.7.1 for Cxx.jl support).

@gasagna
Copy link

gasagna commented May 20, 2016

Is there any temporary workaround for this issue?

@oschulz
Copy link

oschulz commented May 20, 2016

My current workaround is

Pkg.pin("PyCall", v"1.4.0")

;-)

@gasagna
Copy link

gasagna commented May 20, 2016

Thanks! This works for me. PyPlot was unusable after the update.

@oschulz
Copy link

oschulz commented May 23, 2016

Thanks! This works for me. PyPlot was unusable after the update.

Pinning is quickly getting out of hand, though - now I have to pin SymPy too, because the latest version needs a current PyCall, and the last version that works with PyCall 1.4.0 has a problem with Plots.

Any new on this issue, @stevengj ?

@stevengj
Copy link
Member

stevengj commented May 23, 2016

I'm unable to reproduce the problem. I just tried the Homebrew Julia 0.4.5 (on OSX 10.11.4) with the latest PyCall master and the Conda Python (ENV["PYTHON"]=""; Pkg.build("PyCall")) and it works fine for me.

@stevengj
Copy link
Member

I also tried it with /usr/bin/python and a global Anaconda Python install. In all cases, Pkg.test("PyCall") passed.

This is with brew install Caskroom/cask/julia ... is there another julia build I should be trying?

@staticfloat
Copy link
Contributor Author

Ah, I had forgotten about the cask-based Julia build. That's not the homebrew build we're talking about, it doesn't have LLVM assertions enabled. We're talking about this one,

@stevengj
Copy link
Member

Okay, I can reproduce the problem.

@stevengj
Copy link
Member

Nothing to do with global const assignments in __init__ and precompilation, sincd #279 does not eliminate the problem.

@stevengj
Copy link
Member

Seems to be a Julia bug. Here is a minimal module that exhibits the error:

__precompile__()

module PyCall

type PyObject
    o::Ptr{Void} # the actual PyObject*
end

PyNULL() = PyObject(C_NULL)

function jl_Function_call(self_::Ptr{Void}, args_::Ptr{Void}, kw_::Ptr{Void})
    args = PyNULL()
    try
      return C_NULL
    catch e
    finally
        args.o = C_NULL # don't decref
    end
    return C_NULL
end

precompile(jl_Function_call, (Ptr{Void},Ptr{Void},Ptr{Void}))

end # module PyCall

@oschulz
Copy link

oschulz commented May 24, 2016

Thanks for the quick analysis, @stevengj!

@oschulz
Copy link

oschulz commented May 24, 2016

As a workaround (until JuliaLang/julia/#16546 is fixed), it's sufficient to disable line 3155 in julia/src/codegen.cpp:

        // assert(ctx->gensym_assigned.at(idx));

Of course it just hides the underlying issue, but PyCall (and PyPlot, SymPy, etc. on top of it) work fine again so far.

@stevengj
Copy link
Member

stevengj commented Jun 4, 2016

The easiest workaround seems like it would be to download the official Julia binaries for MacOS, rather than using the Homebrew build. If you want a command-line Julia in your path, you can just do

ln -s /Applications/Julia-0.4.5.app/Contents/Resources/julia/bin/julia /usr/local/bin/julia-0.4

@oschulz
Copy link

oschulz commented Jun 4, 2016

The easiest workaround seems like it would be to download the official Julia binaries for MacOS

@stevengj true, however, I have the problem on Linux, too. I need to enable assertions because Cxx.jl doesn't work if they're disabled.

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

No branches or pull requests

5 participants