Skip to content
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

frollapply() issues #3993

Closed
DavisVaughan opened this issue Oct 25, 2019 · 2 comments · Fixed by #3994
Closed

frollapply() issues #3993

DavisVaughan opened this issue Oct 25, 2019 · 2 comments · Fixed by #3994
Milestone

Comments

@DavisVaughan
Copy link
Contributor

DavisVaughan commented Oct 25, 2019

Hi all, I was reading the source for frollapply(), and saw two things that I thought might be problematic.

The first is a protection stack overflow. I think that looping here and constructing a SEXP for both the window and the call for each k is causing this issue. You could probably restructure this loop to be inside the double loop below it (which you might also have to reverse the order of) to only construct them one at a time, and unprotect them after each usage.

pw[j] = PROTECT(allocVector(REALSXP, ik[j])); protecti++;

> frollapply(1, rep(1L, 1e5), identity)
Error: protect(): protection stack overflow

The other is a C stack overflow. I imagine this is related, and comes from constructing this double pointer array on the stack (and maybe the SEXP arrays as well, but im not sure). nk = 1e6 is pretty big.

double *dw[nk];

> frollapply(1, rep(1L, 1e6), identity)
Error: segfault from C stack overflow
@DavisVaughan
Copy link
Contributor Author

I think you also get this C stack overflow from the other double pointer array constructed on the stack

double* dx[nx];

> frollapply(as.list(rep(1, 1e6)), 1, identity)
Error: segfault from C stack overflow

@jangorecki
Copy link
Member

Thanks for reporting. Yes, initialising like that was not good idea, as for large nx we will get segfault easily. Will take a look at your PR soon.

@jangorecki jangorecki added this to the 1.12.7 milestone Nov 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants