-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
World age assertion with setindex!(::SubArray) in a generated function #28595
Comments
While there may be a bug - I thought function generators were meant to be pure? Is |
Sure, this is just after reducing the bug to the bare minimum. Originally, there wasn't any "undefined behavior" of the sort, and the MWE still works (even in the REPL) when fixing the generator usage: _ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: https://docs.julialang.org
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.7.1-pre.0 (2018-08-09 00:19 UTC)
_/ |\__'_|_|_|\__'_| | release-0.7/36cddc1006* (fork: 51 commits, 10 days)
|__/ | x86_64-pc-linux-gnu
julia> bar(x::SubArray) = x[] = 42
bar (generic function with 1 method)
julia> @generated foo(x) = bar(x)
foo (generic function with 1 method)
julia> macro unused() end
@unused (macro with 1 method)
julia> foo(nothing)
julia: /home/tbesard/Julia/julia-dev/src/gf.c:1431: jl_method_instance_add_backedge: Assertion `callee->def.method->min_world <= caller->min_world && callee->max_world >= caller->max_world' failed. (while this specific version should have thrown a |
Just an update: I haven't had time to debug this, but it still reproduces on master as of today (8dd3326), and is still triggered by trivial Cassette usage (eg. JuliaLabs/Cassette.jl#73 (comment)). |
I've debugged this as follows:
the caller is
Because we don't know that the parent array of this subarray isn't another subarray, this ends up in an edgecycle (i.e. backedges are stored in the I'm not entirely sure what the right fix is, but that's how we get the assertion. |
The following "fixes" it, but I assume that also defeats the purpose of the check:
|
This also works:
However, @vtjnash will have to comment what the right answer is. |
Oh, awesome work. Looks to me like the assert here is at fault. I think the only consistency check we can actually verify here is that |
Ok, but that's not true in this case. The callee max world is the same as the callee min world and equal to the world age of the generated function (since it never got expanded). |
Oh, yeah that's never supposed to happen. We needed to allocate a dummy cache entry to have some way to convert the edge into a backedge (but then forgot to create the fake node and then tried to connect the back-edge instead to some unrelated target). |
OK, design should be fixed now where this cannot happen (this assertion has been removed) |
MWE reduced from Cassette (cc @jrevels):
The full thing used to work in the REPL too, but this MWE seems only to work when put in a file:
release-1.0
built with onlyLLVM_ASSERTIONS=1
andFORCE_ASSERTIONS=1
set:The text was updated successfully, but these errors were encountered: