I have this code which producess an error:
import htmlgen import jester
Console output is:
INFO Jester is making jokes at http://0.0.0.0:5000 Starting 8 threads Listening on port 5000 No stack traceback available SIGSEGV: Illegal storage access. (Attempt to read from nil?) Error: execution of an external program failed: '/Users/alex/IdeaProjects/experiments/nnim/app'
I run it with this command: nim c -r app.nim
Apple M1.
What is wrong with it? I just started learning the language.
It means the program was trying to dereference a nil pointer. But it's unknown what caused it to do so. Try adding this:
import std/segfaults
This enables stack-trace for nil deferencingThank you. Added this line, but it didn't fix the problem. Here is the full code and the output:
import std/segfaults
import htmlgen
import jester
routes:
get "/":
resp "hi"
alex@MacBook-Air-5 nnim % nim c -r app.nim
Hint: used config file '/Users/alex/tools/nim/config/nim.cfg' [Conf]
Hint: used config file '/Users/alex/tools/nim/config/config.nims' [Conf]
...............................................................................................................................................................................
/Users/alex/.nimble/pkgs2/jester-0.5.0-a192ca25bfc05d5de5c9a5fafca3b0cee47d82d2/jester.nim(1296, 9) Hint: Synchronous route `match` has been optimised. Use `{.async.}` to change. [User]
/Users/alex/IdeaProjects/experiments/nnim/app.nim(5, 1) template/generic instantiation of `routes` from here
/Users/alex/.nimble/pkgs2/jester-0.5.0-a192ca25bfc05d5de5c9a5fafca3b0cee47d82d2/jester.nim(1331, 39) template/generic instantiation of `async` from here
/Users/alex/tools/nim/lib/pure/asyncmacro.nim(41, 5) Warning: The bare except clause is deprecated; use `except CatchableError:` instead [BareExcept]
/Users/alex/IdeaProjects/experiments/nnim/app.nim(2, 8) Warning: imported and not used: 'htmlgen' [UnusedImport]
CC: ../../../tools/nim/lib/system/exceptions.nim
CC: ../../../tools/nim/lib/system.nim
CC: ../../../tools/nim/lib/pure/segfaults.nim
CC: app.nim
Hint: [Link]
Hint: mm: orc; threads: on; opt: none (DEBUG BUILD, `-d:release` generates faster code)
83401 lines; 1.011s; 166.996MiB peakmem; proj: /Users/alex/IdeaProjects/experiments/nnim/app.nim; out: /Users/alex/IdeaProjects/experiments/nnim/app [SuccessX]
Hint: /Users/alex/IdeaProjects/experiments/nnim/app [Exec]
INFO Jester is making jokes at http://0.0.0.0:5000
Starting 8 threads
Listening on port 5000
Error: execution of an external program failed: '/Users/alex/IdeaProjects/experiments/nnim/app'