Problem
Enzyme.gradient through NonlinearSolve.solve crashes with Illegal inttoptr in LLVM's GC invariant verifier on Julia 1.12. This affects both explicit algorithms (NewtonRaphson()) and the default PolyAlgorithm. The NonlinearSolveBaseEnzymeExt extension loads correctly — the crash happens during Enzyme's LLVM code generation.
Note: Enzyme.gradient through LinearSolve.solve works fine on the same Julia version, so this is specific to NonlinearSolve.
MWE
using NonlinearSolve, Enzyme
f(u, p) = u .^ 2 .- p
function loss(p)
prob = NonlinearProblem(f, [1.0], p)
sol = solve(prob, NewtonRaphson())
sum(sol.u)
end
# Crashes with: Illegal inttoptr
Enzyme.gradient(Enzyme.Reverse, loss, [2.0])
Stack trace (truncated)
Illegal inttoptr
%13 = inttoptr i64 %.unpack3 to ptr addrspace(10), !dbg !87
signal 6 (-6): Aborted
...
run at .../llvm-gc-invariant-verifier.cpp:196
...
post_optimize! at .../Enzyme/src/compiler/optimize.jl:454
_thunk at .../Enzyme/src/compiler.jl:6775
...
augmented_julia_loss_...wrap at ./none:0
Versions
Context
This was discovered while verifying the fix for #869 (polyalgorithm type inference). The inference fix (#870) resolves the MixedReturnException on Julia 1.10 where the Enzyme extension works. This issue tracks the separate LLVM-level crash on Julia 1.12.
🤖 Generated with Claude Code
Co-Authored-By: Chris Rackauckas accounts@chrisrackauckas.com
Problem
Enzyme.gradientthroughNonlinearSolve.solvecrashes withIllegal inttoptrin LLVM's GC invariant verifier on Julia 1.12. This affects both explicit algorithms (NewtonRaphson()) and the defaultPolyAlgorithm. TheNonlinearSolveBaseEnzymeExtextension loads correctly — the crash happens during Enzyme's LLVM code generation.Note:
Enzyme.gradientthroughLinearSolve.solveworks fine on the same Julia version, so this is specific to NonlinearSolve.MWE
Stack trace (truncated)
Versions
Context
This was discovered while verifying the fix for #869 (polyalgorithm type inference). The inference fix (#870) resolves the
MixedReturnExceptionon Julia 1.10 where the Enzyme extension works. This issue tracks the separate LLVM-level crash on Julia 1.12.🤖 Generated with Claude Code
Co-Authored-By: Chris Rackauckas accounts@chrisrackauckas.com