-
Notifications
You must be signed in to change notification settings - Fork 596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running 2nd map2stan() model with rstan 2.14.1 leads to segfault #65
Comments
Thanks for the report. This happens only when the model definitions are the same? If so, maybe related to how Stan reuses the compiled model binary. |
A little experimentation later, still not sure what is causing the problem. But using the previous map2stan result seems to bypass it:
Hopefully that's a useful workaround for others, until I can figure out the core issue. |
I think you are correct that stan reusing the compiled model leads to the failure. If you delete the relevant files from the tmp directory, the same model will run twice.
|
I haven't had any luck figuring out the root cause. I thought perhaps it was a mismatch between the model name that map2stan uses and the model name internal to the stanfit object and module. But making those identical didn't change anything. It's perhaps related to this general bug with stan, in which it keeps links to removed objects: |
I can reliably prevent the segfault by simply making a copy of the stanfit object in the global environment:
As soon as the
No idea what this means. |
Not surprising, because it's a Windows fix, but this commit stan-dev/rstan@6a61721 does not fix the crash on OS X. Your code above leads to crash with recompiled rstan from the develop tree:
|
I've been working through the excellent Rethinking book and have encountered the same problem. Everything worked well until I got to the map2stan examples in Chapter 10 and then R started to crash whenever I run a given map2stan more than once. (When I call map2stan with a 'map' model as the input R crashes the first time I run the code.) (Also, as an aside, the function logistic doesn't seem to exist in the rethinking package. Or at least I can't find it.) |
I just pushed to the Experimental branch a solution to this issue. It's not a long-term solution, because it prevents Stan from reusing the compiled model. It forces recompilation. But it does stop the segfaults. |
Thanks for letting me know. I've really enjoyed the book.
Jeff Miller
…Sent from my iPhone
On Feb 21, 2017, at 7:48 AM, Richard McElreath ***@***.***> wrote:
I just pushed to the Experimental branch a solution to this issue. It's not a long-term solution, because it prevents Stan from reusing the compiled model. It forces recompilation. But it does stop the segfaults.
https://github.com/rmcelreath/rethinking/tree/Experimental
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Works well. I know it's not an ideal fix, but for me, recompiling models is less aggravating than starting over completely after a segfault. |
Experimental branch work-around is working for people:
|
Kinda fixed for now, through workaround. Closing the issue, but still worrying about the underlying cause. |
After the rstan 2.14.1 (it might have been 2.14, but at least by 2.14.1), running a second map2stan() model in the same R session causes a segfault in my setup. Example:
Gives:
I am running R 3.3.2 Patched and reinstalled rethinking and all dependencies from source. I'm not sure if this is reproducible by anyone else.
My sessionInfo():
The text was updated successfully, but these errors were encountered: