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

Codegen assertion fails in 1.5.0-DEV.51 #50

Open
phipsgabler opened this issue Feb 17, 2020 · 3 comments
Open

Codegen assertion fails in 1.5.0-DEV.51 #50

phipsgabler opened this issue Feb 17, 2020 · 3 comments

Comments

@phipsgabler
Copy link
Contributor

I have been observing an assertion failure in codegen.cpp since about a month on nightly (see here), but couldn't yet find a minimal example.

codegen.cpp:4353: jl_cgval_t emit_expr(jl_codectx_t&, jl_value_t*, ssize_t): Assertion `token.V->getType()->isTokenTy()' failed.

signal (6): Aborted
in expression starting at /home/travis/build/phipsgabler/DynamicComputationGraphs.jl/test/test_basics.jl:6
gsignal at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x7f25a5a3cbd6)
__assert_fail at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
emit_expr at /buildworker/worker/package_linux64/build/src/codegen.cpp:4353

Maybe this change has something to do with it -- the part of the code causing this is where gc_preserve_end_sym expressions are handled.

@MikeInnes
Copy link
Member

It would be great to understand whether this actually comes from IRTools or the package (e.g. by showing that a no-op dynamo errors like this). And if so, helpful if we can narrow it down to a specific function that causes the error, and it's likely pretty easy to fix.

@phipsgabler
Copy link
Contributor Author

I talked to @simeonschaub on Slack about it, maybe he has a shorter example?

@simeonschaub
Copy link
Member

Here's a more minimal example that crashes on nightly:

using IRTools: @dynamo, IR, recurse!, block, branches, branch!

macro mark(ex)
    return Expr(
        :block,
        Expr(:meta, :begin_mark),
        esc(ex),
        Expr(:meta, :end_mark),
    )
end

@dynamo function skip(x...)
    ir = IR(x...)
    ir === nothing && return

    tape = []

    for (x, st) in ir
        is_layer_begin = Meta.isexpr(st.expr, :meta) &&
            st.expr.args[1] === :begin_mark
        is_layer_end =  Meta.isexpr(st.expr, :meta) &&
            st.expr.args[1] === :end_mark

        if is_layer_begin
            push!(tape, :a)
        elseif is_layer_end
            pop!(tape)
        end
    end

    recurse!(ir)
    return ir
end

function inner()
    ret = Int[]
    push!(ret, 2)
    @mark push!(ret, 3)
    ret
end

function outer()
    ret = Int[]
    push!(ret, 1)
    x = inner()
    append!(ret, x)
    @mark push!(ret, 4)
    push!(ret, 5)
    ret
end

skip(outer)

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

3 participants