Stackoverflow error with no stacktrace

I’m experienceing a strange bug which results in a stack overflow error with no stacktrace at all. I’m not sure how or why this happens, and I have found it impossible to diagnose. I haven’t been able to reprodruce the bug with a minimized example… :confused:

Has anyone experienced anything similar? Is there a way to recover the stacktrace (from the most recent exception) to look for clues?

Update.

I’ve narrowed down the error slightly. It appears with the following line

diffcfg = ForwardDiff.GradientConfig(f, θ, ForwardDiff.Chunk{length(θ)}())
ForwardDiff.gradient!(diffresult, f, θ, diffcfg, Val{true}())

But not when I remove my diffcfg.

ForwardDiff.gradient!(diffresult, f, θ)

Going to dig further, leaving this trail of breadcrumbs incase anyone else faces a similar issue

Replacing

# OLD, wrong
ForwardDiff.Chunk{length(θ)}()

# NEW, good
ForwardDiff.Chunk(θ)

I think this results in a different chunk size being chosen (12 is the default threshold) instead of 22. I’m done for now, not sure how the previous case caused stack overflow, or why it should do so WITHOUT showing a stacktrace.

For reference, here is the Chunk function from ForwardDiff

function Chunk(input_length::Integer, threshold::Integer = DEFAULT_CHUNK_THRESHOLD)
    N = pickchunksize(input_length, threshold)
    0 < N <= DEFAULT_CHUNK_THRESHOLD && return CHUNKS[N]
    return Chunk{N}()
end

Try using the ‘err’ global, if you’re running on the REPL? The most recent exception should go there.

2 Likes