# How to isolate & report non-deterministic bug

**URL:** https://discourse.julialang.org/t/how-to-isolate-report-non-deterministic-bug/127176
**Category:** General Usage
**Tags:** question, bug, regression
**Created:** [March 20, 2025, 2:42pm UTC](https://discourse.julialang.org/t/how-to-isolate-report-non-deterministic-bug/127176 "2025-03-20T14:42:59Z")
**Posts on this page:** 1
**Showing post:** 12

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [March 26, 2025, 5:09pm UTC](https://discourse.julialang.org/t/how-to-isolate-report-non-deterministic-bug/127176/12 "2025-03-26T17:09:44Z")

</div>

I tried bisecting and narrowed it down to a handful (~15) of commits, of which

> <https://github.com/JuliaLang/julia/pull/57201>
>
> Fixes https://github.com/JuliaLang/julia/issues/57141.
> 
> Given the function
> 
> …\`\`\`julia
> julia\> function \_f()
> ref = Ref{Any}()
> ref\[\] = 3
> @assert isdefined(ref, :x)
> inner = Returns(ref)
> x = inner()
> (x, ref\[\])
> end
> \_f (generic function with 1 method)
> 
> julia\> f() = first(\_f())
> f (generic function with 1 method)
> \`\`\`
> 
> Here is before:
> \`\`\`julia
> julia\> @code\_typed f()
> CodeInfo(
> 1 ─ %1 = %new(Base.RefValue{Any})::Base.RefValue{Any}
> └── goto #3
> 2 ─ unreachable
> 3 ─ return %1
> ) =\> Base.RefValue{Any}
> \`\`\`
> 
> Here is after this PR:
> \`\`\`julia
> julia\> @code\_typed f()
> CodeInfo(
> 1 ─ %1 = %new(Base.RefValue{Any})::Base.RefValue{Any}
> │ builtin Base.setfield!(%1, :x, 3)::Int64
> │ %3 = builtin Main.isdefined(%1, :x)::Bool
> └── goto #3 if not %3
> 2 ─ goto #4
> 3 ─ %6 = invoke Base.AssertionError("isdefined(ref, :x)"::String)::AssertionError
> │ builtin Base.throw(%6)::Union{}
> └── unreachable
> 4 ─ return %1
> ) =\> Base.RefValue{Any}
> \`\`\`
> 
> The elimination of \`setfield!\` was due to a use still being recorded for \`ref\[\]\` in the def-use data while DCE eliminated this \`getindex\` call (by virtue of not using the second tuple element in the result).

is the most likely suspect (for fixing it). Evidence for this is circumstantial (see below), but I think it is pretty likely: it was OK in 1.10, broken in 1.11, fixed in master, and indeed a `setfield!` form is missing from the lowered expression.

On a related note, I found bisecting a Julia with a nontrivial reproducer (that uses a lot of packages) quite challenging. I am running into issues with resolving packages (in theory, one can always go up and keep the `Manifest.toml`, but if some packages lower bound then this breaks), and I am running into issues like

> [@ERROR: LoadError: could not load symbol "jl\_tag\_newly\_inferred\_enable"](https://discourse.julialang.org/t/error-loaderror-could-not-load-symbol-jl-tag-newly-inferred-enable/127356/2):
>
> How to reproduce: check out the Julia repository at eg fea26ddecb8a6c404f0c501228bf17c9b384d686 and compile, start julia, thenpkg\> activate --temp pkg\> add StaticArrays@1.9.13 gives the above error message.

which eventually prevented me from pinning this down.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-isolate-report-non-deterministic-bug/127176)._
