Closed nixfreak closed 1 year ago
run it with nimble rund
for debug mode and see where it crashes.
SIGSEGV: Illegal storage access. (Attempt to read from nil?) Error: execution of an external program failed: '/Users/.env/nim/practice/ud_nim_programming/nico/conway/conway ' stack trace: (most recent call last) /private/var/folders/81/zn5n71012mb48jwlptm46_m80000gq/T/nimblecache-1664209541/nimscriptapi_969186685.nim(187, 16) /Users/.env/nim/practice/ud_nim_programming/nico/conway/conway.nimble(23, 7) rundTask /Users/.choosenim/toolchains/nim-1.6.4/lib/system/nimscript.nim(273, 7) exec /Users/.choosenim/toolchains/nim-1.6.4/lib/system/nimscript.nim(273, 7) Error: unhandled exception: FAILED: nim c -r -d:debug -o:conway src/main.nim [OSError] Tip: 1 messages have been suppressed, use --verbose to show them. Error: Exception raised during nimble script execution
Ok , I figured out the issue. It's weird though that this should of failed during the proc and not illegal storage..
Anyway this is why I couldn't see the issue: setColor(3) boxfill(10,20,100,50) where not in scope of the proc at all.
`proc gameDraw() = cls()
setColor(3) boxfill(10,20,100,50)
` Closing ticket.
nimble runr --verbose [11:05:44] Warning: Package 'conway' has an incorrect structure. The top level of the package source directory should contain at most one module, named 'conway.nim', but a file named 'main.nim' was found. This will be an error in the future. Hint: If this is the primary source file in the package, rename it to 'conway.nim'. If it's a source file required by the main module, or if it is one of several modules exposed by 'conway', then move it into a 'conway/' subdirectory. If it's a test file or otherwise not required to build the the package 'conway.nim', prevent its installation by adding
skipFiles = @["main.nim"]
to the .nimble file. See https://github.com/nim-lang/nimble#libraries for more info. Executing task runr in /Users/.env/nim/practice/ud_nim_programming/nico/conway/conway.nimble Hint: used config file '/Users/.choosenim/toolchains/nim-1.6.4/config/nim.cfg' [Conf] Hint: used config file '/Users/.choosenim/toolchains/nim-1.6.4/config/config.nims' [Conf] Hint: used config file '/Users/.env/nim/practice/ud_nim_programming/nico/conway/config.nims' [Conf] Hint: gc: refc; opt: speed; options: -d:danger 19456 lines; 0.069s; 16.531MiB peakmem; proj: /Users/.env/nim/practice/ud_nim_programming/nico/conway/src/main.nim; out: /Users/nim/practice/ud_nim_programming/nico/conway/conway [SuccessX] Hint: /Users/.env/nim/practice/ud_nim_programming/nico/conway/conway [Exec]SIGSEGV: Illegal storage access. (Attempt to read from nil?) Error: execution of an external program failed: '/Users/.env/nim/practice/ud_nim_programming/nico/conway/conway ' stack trace: (most recent call last) /private/var/folders/81/zn5n71012mb48jwlptm46_m80000gq/T/nimblecache-1664209541/nimscriptapi_969186685.nim(187, 16) /Users/.env/nim/practice/ud_nim_programming/nico/conway/conway.nimble(20, 7) runrTask /Users/.choosenim/toolchains/nim-1.6.4/lib/system/nimscript.nim(273, 7) exec /Users/.choosenim/toolchains/nim-1.6.4/lib/system/nimscript.nim(273, 7) Error: unhandled exception: FAILED: nim c -r -d:danger -o:conway src/main.nim [OSError] Tip: 1 messages have been suppressed, use --verbose to show them. Error: Exception raised during nimble script execution
I have run the code using
nimble runr
and alsonim c -r ./src/main.nim
The file compiles just fine but I cannot execute the file.Code:
`import nico import std/sequtils
let title = "Jonathan's game of life" let wx = 600 let wy = 400 let resolution = 10 let dx = resolution let dy = resolution let nx = wx div dx let ny = wy div dy
var board = newSeqWith(nx, newseqbool) board[0][0] = true board[10][0] = true board[0][5] = true
var buttonDown = false
proc gameInit() = loadFont(0, "font.png")
proc gameUpdate(dt: float32) = buttonDown = btn(pcA)
proc gameDraw() = cls()
setColor(if buttonDown: 7 else: 3)
printc("welcome to " & appName, screenWidth div 2, screenHeight div 2)
setColor(3) boxfill(10,20,100,50)
nico.init("myOrg", title) nico.createWindow("myApp", wx, wy, 1, false) nico.run(gameInit, gameUpdate, gameDraw)`