-
Notifications
You must be signed in to change notification settings - Fork 156
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
Crashes in calls of functions generated with Symbolics.build_function
#651
Comments
Is this a standard generic Julia binary from https://julialang.org/? |
Yes, it is. |
Here's a minimal reproducer that reliably triggers the issue for me: using Symbolics
using SparseArrays
function main(; n=10000, m=10000, nsp=10)
x = begin
@variables(x[1:n],) |> only |> Symbolics.scalarize
end
f = map(1:m) do _
ind = rand(eachindex(x), nsp)
sum(x -> x^2, x[ind])
end
J = Symbolics.sparsejacobian(f, x)
(J_rows, J_cols, J_vals) = findnz(J)
J_vals_fn! = Symbolics.build_function(J_vals, x; expression=Val{false})[2]
sparse_J = (; rows=J_rows, cols=J_cols, (vals_fn!)=J_vals_fn!)
result = zeros(length(sparse_J.rows))
input = rand(length(x))
sparse_J.vals_fn!(result, input)
result
end |
I should probably add here that I have opened an issue in Base instead because it seems the more appropriate place for this kind of bug. That issue is also strictly more informative than this one by now, since I've added an rr-trace and git bisect results. So to the maintainers here: feel free to close this issue if you don't think that there is any value in tracking it here as well. |
Symbolics.build_function
Symbolics.build_function
I think Jeff found the issue and fixed it today. I have a fix for this that makes it work within Symbolics, I'll close this issue with that change. |
Should be fixed by JuliaLang/julia#45173 |
I tested the reproducer above with JuliaLang/julia#45173 and the bug does not occur anymore. I should also say, however, that on nightly (even without that PR) the problem seemed to be fixed (though probably only symptomatically). |
In some of my research code, I am seeing sporadic crashes for functions generated by
Symbolics.build_functions
incodegen.cpp
Click to see the full backtrace captured with gdb.
It does not happen every time but the frequency seems to correlate with:
Unfortunately, I have thus far been unable to create a compact reproducer that does not involve a ton of my research code. However, I have a setup to reproduce this issue locally with gdb and am happy to provide more information if necessary.See reproducer below.
Version Info
The text was updated successfully, but these errors were encountered: