Segfault that I cannot explain, possibly related to Zygote

cortner
Wed, 12 Jan 2022 20:20:18 +0000
General Usage

Naively maybe, I assumed that segfaults will only occur if I access memory I don’t own. Therefore, in Julia, with bounds checking turned on, it simply shouldn’t occur?

I’ve now run into a case where the opposite happens. I don’t know where to start debugging. I can’t even judge whether this is a problem in my code or in a library I’m using (if the latter, then likely Zygote) or in Julia itself. More on my code below (I apologize that I was unable to produce a MWE.), but here are the observations for now, all with Julia 1.7.1, on an M1, compiled from source. (It appears it does not occur with downloaded versions of 1.6.4, 1.7.0, 1.7.1 - rosetta; but it does occur with a downloaded version of Julia 1.7.1 - native M1.)

The script tests some rrule implementations by constructing some simple nonlinear models, differentiating them with Zygote (using the custom rrule implementations) and then checking them with finite differences. The following tests all run ok with all tests passing, and no segfaults:

julia --project=.. test_admodel.jl
julia --project=.. --check-bounds=yes test_admodel.jl
julia -O3 --project=.. test_admodel.jl

But if I turn on bounds checking AND O3, I get a segfault in one of the tests:

julia -O3 --project=.. --check-bounds=yes test_admodel.jl

NOTE: After the last PR, this has actually changed - but can still reproduce the same behaviour if test_admodel.jl is replaced with runtests.jl. So it is not entirely reproducible, but I guess this is not unusual for segfaults; small changes to the code can change the behaviour?

I would be very grateful for any general thoughts how segfaults might occur when all bounds-checking is turned on, or directions on where to best file this as a bug report.
Full segfault report: (click for more details)
Just in case anybody is actually interested in reproducing this problem, here are the instructions:
Setup and run the tests: (click for more details)
1 post - 1 participant