httpbeast icon indicating copy to clipboard operation
httpbeast copied to clipboard

SIGSEGV when running a basic jester 0.6.0 server in nim 2.0 on M1 Mac

Open sklarsa opened this issue 2 years ago • 3 comments

I have a simple file:

import htmlgen
import jester

routes:
  get "/":
    resp h1("Hello world")

and when I compile, I get the following output:

$ nim c -r --gc:orc src/server
command line(1, 2) Warning: `gc:option` is deprecated; use `mm:option` instead [Deprecated]
Hint: used config file '/Users/steven/.choosenim/toolchains/nim-2.0.0/config/nim.cfg' [Conf]
Hint: used config file '/Users/steven/.choosenim/toolchains/nim-2.0.0/config/config.nims' [Conf]
Hint: mm: orc; threads: on; opt: none (DEBUG BUILD, `-d:release` generates faster code)
10086 lines; 0.027s; 10.484MiB peakmem; proj: /Users/steven/source/github/questdb-partition-manager/src/server; out: /Users/steven/source/github/questdb-partition-manager/src/server [SuccessX]
Hint: /Users/steven/source/github/questdb-partition-manager/src/server [Exec]
INFO Jester is making jokes at http://0.0.0.0:5000
Starting 8 threads
Listening on port 5000
Traceback (most recent call last)
/Users/steven/.nimble/pkgs/httpbeast-0.4.1/httpbeast.nim(83) eventLoop
/Users/steven/.choosenim/toolchains/nim-2.0.0/lib/system/orc.nim(46) nimIncRefCyclic
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Error: execution of an external program failed: '/Users/steven/source/github/questdb-partition-manager/src/server'

Nim Info

$ nim -V
Nim Compiler Version 2.0.0 [MacOSX: amd64]
Compiled at 2023-08-13
Copyright (c) 2006-2023 by Andreas Rumpf

active boot switches: -d:release

sklarsa avatar Aug 13 '23 20:08 sklarsa

I'm having the same issue:

import jester
import htmlgen

routes:
  get "/":
    resp h1("Guten Morgen")

Running it runs into a SIGSEGV:

% nim c -r src/nimapi.nim
Hint: used config file '/opt/homebrew/Cellar/nim/2.0.0_1/nim/config/nim.cfg' [Conf]
Hint: used config file '/opt/homebrew/Cellar/nim/2.0.0_1/nim/config/config.nims' [Conf]
...............................................................................................................................................................................
/Users/louis/.nimble/pkgs2/jester-0.6.0-4834f85e61ae39f6b6acfb74d3bbba62d8779b66/jester.nim(1345, 9) Hint: Asynchronous route: match. [User]
Hint:  [Link]
Hint: mm: orc; threads: on; opt: none (DEBUG BUILD, `-d:release` generates faster code)
83886 lines; 0.768s; 167.531MiB peakmem; proj: /Users/louis/Git/nimapi/src/nimapi.nim; out: /Users/louis/Git/nimapi/src/nimapi [SuccessX]
Hint: /Users/louis/Git/nimapi/src/nimapi [Exec]
INFO Jester is making jokes at http://0.0.0.0:5000
Starting 8 threads
Listening on port 5000

Traceback (most recent call last)
/Users/louis/.nimble/pkgs2/httpbeast-0.4.1-b23e57a401057dcb9b7fae1fb8279a6a2ce1d0b8/httpbeast.nim(83) eventLoop
/opt/homebrew/Cellar/nim/2.0.0_1/nim/lib/system/orc.nim(46) nimIncRefCyclic
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Error: execution of an external program failed: '/Users/louis/Git/nimapi/src/nimapi'

Using Nim:

% nim -v
Nim Compiler Version 2.0.0 [MacOSX: arm64]
Compiled at 2023-08-01
Copyright (c) 2006-2023 by Andreas Rumpf

active boot switches: -d:release -d:nimUseLinenoise

louis77 avatar Aug 19 '23 09:08 louis77

Just found a work around:

You can add -d:useStdLib in your nim.cfg, and jester will use std/asynchttpserver instead of httpbeast.

And it works!

danny1113 avatar Aug 24 '23 04:08 danny1113

@danny1113 - this should also be solved in PR https://github.com/dom96/httpbeast/pull/89 . httpbeast git-tag is not updated yet, so you need to either use #head or manually cloning and installing.

ThomasTJdev avatar Aug 24 '23 14:08 ThomasTJdev