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

rast(array(1)) uses entire system memory #1254

Closed
andreimirt opened this issue Aug 5, 2023 · 2 comments
Closed

rast(array(1)) uses entire system memory #1254

andreimirt opened this issue Aug 5, 2023 · 2 comments

Comments

@andreimirt
Copy link

obviously, array(1) was not my real data, but when trying to use an array to create a SpatRaster, it tried to use the entire system memory, and the entire pagefile. (128GB x 2)
Interestingly enough, it didn't crash the system, as the memory went down, and then up again.
I am running windows 10, R 4.3.1, and terra 1.7.39
Code to reproduce is simply rast(array(1))

@andreimirt
Copy link
Author

by looking at the source code of rast, it's obvious that I'm misusing it, as it's supposed to handle mutidimensional arrays.
I was hoping to be able to give rast a list of values, an extent, and optionally a crs, and rast to figure that I want those values arranged uniformly inside the extent.

Instead, it caused an unintended DOS attack on my PC.

andreimirt added a commit to andreimirt/terra that referenced this issue Aug 5, 2023
rast has a bug that occupies the entire memory if provided a unidimensional array. This fixes it by actually creating a uniform rast out of a unidimensional array. See rspatial#1254
@rhijmans
Copy link
Member

Thanks for reporting this. Very ugly. I now get:

library(terra)
#terra 1.7.41
rast(array(1))
#Error: [rast,array] cannot handle an array with less than 3 dimensions

I do not fully understand what functionality you are looking for; but I would be happy to look at that if you can clarify.

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

No branches or pull requests

2 participants