ModelingToolkit takes forever to precompile on Windows 11

I had the problem with BoundaryValueDiffEq precompilation going forever.
I did uncheck the “Read-only” for the .julia folder, and it got fixed for me.
Screenshot 2024-05-23 212546

Some updates:

  1. Still mysterious, maybe even more mysterious than yesterday due to the stochastic behavior.
  2. It was reproduced with using Parsers without having ModelingToolkit or OrdinaryDiffEq installed, so it’s something deeper, though maybe OrdinaryDiffEq is just good at triggering it.
  3. The compiler team is looking into it.
4 Likes

By the way Parsers.jl does have a buffer overflow problem during precompilation on 1.11 and above, Buffer Overflow during precompile · Issue #189 · JuliaData/Parsers.jl (github.com). I’m guessing that’s not causing this issue especially because the reports seem to be from 1.10, but just thought you might want to be aware.

No, people have recreated the same GC segfault exception on Windows on v1.10.3.

Parsers and MKT will install on Julia 1.9.4 without issue. Not sure if the information help to diagnose or not.

Together with @gbaraldi, we are fairly certain we’ve isolated this to a linker problem, related to pseudo relocation support in MinGW.

The problem has been present for a long time, but only causes major issues in sufficiently large pkgimages.

This probably won’t get a workaround in the mean time - It will almost certainly need a hotfix release to fix properly, but we’re trying to get that out asap.

10 Likes

We put out a few releases that we believe might work around the issue. Could someone who has the issue update (specifically OrdinaryDiffEq and MTK) and see if the probability of hitting the issue is now near 0?

I hit the issue yesterday on my work laptop. For OrdinaryDiffEq and MTK it worked on first attempt today with the updates. I had another project pulling in the full DifferentialEquations package. There I hit the bug in BoundaryValueDiffEq on the first attempt but working on second attempt.

Thank you to everyone involved for providing a work around.

An update. Precompile seems to work but it seems the bug is now triggering for me during a call to solve. Not sure if I messed something else up.

I can confirm that for me ModelingToolkit 9.15.0 precompiles with either OrdinaryDiffEq@6.78.0 or @6.79.1.

Yesterday, on ModelingToolkit 9.14.0, it never precompiled on OrdinaryDiffEq@6.78.0 (I tried ~10 times), while it did on ODE@6.77.0 occasionally.

Thanks for the detective work!

1 Like

Are you able to solve an ODE using the updated packages?

For me the most reliable solution is still to pin OrdinaryDiffEq to 6.75.

Indeed, if I run the example: Acausal Component-Based Modeling · ModelingToolkit.jl
everything precompiles, but at the ‘solve’ I consistently hit:

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x7ffb847676bf -- gc_setmark_pool_ at C:/workdir/src\gc.c:876 [inlined]
gc_setmark_pool at C:/workdir/src\gc.c:895 [inlined]
gc_setmark at C:/workdir/src\gc.c:902 [inlined]
gc_setmark at C:/workdir/src\gc.c:898 [inlined]
gc_mark_outrefs at C:/workdir/src\gc.c:2606 [inlined]
gc_mark_loop_serial_ at C:/workdir/src\gc.c:2679
in expression starting at c:\Users\guill\Documents\AGU\MyPkg\test\tt.jl:86
...

On my usecase, I am dependent on ModelingToolkit via OptimisationMOI. For this scenario, the last releases did the trick.

We can pull the new default ODE solver alg as it seems to hit the GC bug due to code size

Is the GC bug only influencing the precompilation stage? Or does it also influence the import (“using…”) and running of code?

If only precompilation, would it help to first add one of the larger dependencies of ModelingToolkit , e.g., OrdinaryDiffEq, then exit Julia (assuming that exit finishes GC), then restart Julia & add (the rest of) ModelingToolkit, exit and restart Julia, add a next package, and so on?

it’s not exactly a GC bug. The actual problem is a linker bug in lld, which causes the package images that precompilation creates to be loaded incorrectly. This incorrect loading means that the GC will see invalid data and segfault or throw an error.

2 Likes

Try OrdinaryDiffEq v6.80.0. This should now work around this for even more cases. It should be put to rest finally.

The Pkg didn’t find 6.80.0 – so perhaps not published yet?

1 Like

Same error on solve for me on OrdinaryDiffEq v6.80.0 (commit 5144bfa).

that’s unfortunate. looks like this won’t be resolved until the issue is fixed for real on the Julia side.

Which, as a breadcrumb, is being worked on in