It also happened to me when the app or the script running try to access a restricted part of the memory or when there is not enough RAM

Since your script does not crash on my ipad pro 2017 (4GBs of RAM) too, i believe it's the second option