Error in unserialize, rstan 2.18, problems with native mtune and march

Model compiles but trying sampling() now results in a fatal error, R session aborted. I tried cores = 1 with and without the -mtune=native -march=native in the Makevars file.

It may be worth noting that with my machine, parallel::detectCores(logical=TRUE) gives 8 while parallel::detectCores(logical=FALSE) gives 4

Edit: On a whim I decided to try switching the ODE solver in my model from integrate_ode_bdf() to integrare_ode_rk45. Now I don’t get a fatal error or an “Error in (un)serialize” but the sampling is not done and I get this error:

[1] "Error in sampler$call_sampler(args_list[[i]]) : "                                                   
[2] "  Exception: Max number of iterations exceeded (1000000).  (in 'model468f90242a_stage2' at line 88)"
[1] "error occurred during calling the sampler; sampling not done"

This looks like the program actually started to run but had some problem with the ode solver, which is a problem I can play around with on my own to try to fix. So maybe there’s some kind of issue with the parallelization in integrate_ode_bdf() ?