-
-
Save izackp/107a8f733c686276d396e30f65249d7c to your computer and use it in GitHub Desktop.
Nim OOM Tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type | |
FatArray = array[50_000_000, uint8] | |
FatArrayRef = ref FatArray | |
var container: array[50_000_000, FatArrayRef] | |
var i = 0 | |
while true: | |
try: | |
# Will eventually return nil | |
var x:FatArrayRef = new FatArray | |
container[i] = x | |
i += 1 | |
echo i | |
except: | |
echo getCurrentExceptionMsg() | |
let ose = getCurrentException() | |
echo ose.name | |
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type | |
FatArray = array[50_000, uint8] | |
var container = newSeq[FatArray](1) | |
var i = 0 | |
while true: | |
try: | |
#Will eventually hang | |
var x:FatArray | |
x[0]=5 | |
container.add(x) | |
i += 1 | |
echo i | |
except: | |
echo getCurrentExceptionMsg() | |
let ose = getCurrentException() | |
echo ose.name | |
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type | |
FatArray = array[50_000_000, uint8] | |
# Doesn't compile needs a const size | |
proc fatStack(size:int) = | |
var container: array[size, FatArray] | |
var i = 0 | |
try: | |
var x:FatArray | |
container[i] = x | |
i += 1 | |
except: | |
echo getCurrentExceptionMsg() | |
let ose = getCurrentException() | |
echo ose.name | |
var size = 1 | |
while true: | |
try: | |
fatStack(size) | |
size += 1 | |
echo size | |
except: | |
echo getCurrentExceptionMsg() | |
let ose = getCurrentException() | |
echo ose.name | |
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From within newSeq: | |
# SIGSEGV: Illegal storage access. (Attempt to read from nil?) | |
var container = newSeq[uint64](50_000_000*50_000_000) | |
container[0] = 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Linker Error: ARM64 ADRP out of range (20000000024576 max is +/-4GB): from _main (0x100006F20) to _gEnv (0x12319CE606F0) in '_main' from @moomStackSafe.nim.cpp.o for architecture arm64 | |
var container: array[50_000*50_000_000, uint64] | |
container[0] = 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Program terminates with error code 1 after 2 iterations | |
proc fatStack(depth:int) = | |
var fatty:array[500_000, uint64] | |
try: | |
fatty[0] = 1 | |
echo depth | |
if (depth > 0): | |
fatStack(depth + 1) | |
except: | |
echo getCurrentExceptionMsg() | |
let ose = getCurrentException() | |
echo ose.name | |
fatStack(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment