-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Indexing out-of-bounds not always handled properly #776
Comments
edit: @SteveBronder has looked at the generated code. |
Ah, interesting! Is it the case that this only happens on index literals (eg |
Unfortunately not. data {
int N;
}
transformed data {
vector[N] x[2];
}
parameters {
real theta;
}
model {
theta ~ normal(x[N][1], 1);
} suffers from the same issue. |
Only if N = 0? |
Indeed. |
I ran into someone having this problem today. They were getting the error:
I'm into putting @nhuurre 's patch back in and then in the future someone can fix the performance thing with rvalue. |
@rybern I vaguely remember reading in an issue somewhere about rvalues and when to use them for assignments or not. Are you in r-value land now? I forgot about this bug, but apparently it was fixed by forcing everything to go through rvalue (#521). We reverted that fix for performance reasons, but never got a fix for this in. |
@bbbales2 Not currently in r-value land, I'd have to spend some time catching up on this |
@rybern ah ah, I thought I remembered something about accessing arrays directly and that reminded me of this. Anyway I guess it's something different so don't context switch into this just yet. Someone else might have a fix for this laying around. Will check in with @rok-cesnovar on it tomorrow. |
When indexing a Stan array or vector with an index that's out-of-bounds, the Stan program terminates with different error conditions:
Examples
This triggers an Eigen assertion:
This seg faults (may not consistently seg fault):
This looks like it's reading off the end of memory:
I believe @bbbales2 has looked at the generated C++ and confirmed the issue.
The text was updated successfully, but these errors were encountered: