prologue icon indicating copy to clipboard operation
prologue copied to clipboard

SIGSEGV: Illegal storage access. (Attempt to read from nil?)

Open lost22git opened this issue 2 years ago • 9 comments

  • os

WSL2 Debian 12

  • code
import prologue

proc hello*(ctx: Context) {.async.} =
  resp "<h1>Hello, Prologue!</h1>"

let app = newApp()
app.get("/", hello)
app.run()
  • nimble file
# Package

version       = "0.1.0"
author        = "lost22git"
description   = "A new awesome nimble package"
license       = "MIT"
srcDir        = "src"
bin           = @["test_prologue"]


# Dependencies

requires "nim >= 2.0.0", "prologue >= 0.6.4"
  • build and run
nimble build -d:release
./test_prologue
  • wrk test
ulimt -n 1000000
wrk -c 10000 -d 30s http://localhost:8080
  • error message
DEBUG Prologue is serving at http://0.0.0.0:8080
DEBUG Starting 16 threads
DEBUG Listening on port 8080
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Segmentation fault

lost22git avatar Aug 15 '23 22:08 lost22git

I just got the exact same error on Arch using siege for concurrency testing - same nim + prologue versions, and same test code 😆

ahungry avatar Aug 29 '23 01:08 ahungry

I downgraded some deps:

nim = 1.6.0 prologue = 0.5.0

No more error - a prologue downgrade didn't fix the issue, so I'm thinking it's something in the nim 2.0 (I'll try the last non 2.0 version for comparison with the latest prologue possible).

ahungry avatar Aug 29 '23 01:08 ahungry

I also noticed the (per request) DEBUG log does not show on nim 2.0 either - only the boot up message does.

ahungry avatar Aug 29 '23 01:08 ahungry

These versions do not produce the issue:

requires "nim == 1.6.14"
requires "prologue == 0.6.4" 

ahungry avatar Aug 29 '23 01:08 ahungry

https://github.com/nim-lang/Nim/issues?q=is%3Aissue+is%3Aopen+sigsegv+ - looks like a lot of this in 2.0 release usage.

ahungry avatar Aug 29 '23 01:08 ahungry

Maybe helpful to prologue, httpbeast is having a similar issue: https://github.com/nim-lang/Nim/issues/21422

ahungry avatar Aug 29 '23 01:08 ahungry

One stack trace mentioned httpx for me - and if I use -d:usestd, I no longer receive the error (on nim 2.0) - so I'm guessing this is something httpx is doing incorrectly.

ahungry avatar Aug 29 '23 01:08 ahungry

I updated httpx issue here: https://github.com/ringabout/httpx/issues/33 with a link to the httpbeast solution - I think httpx needs to incorporate it from httpbeast HEAD, add a new tag, then include the new tag on prologue.

ahungry avatar Aug 29 '23 01:08 ahungry

Another workaround is to use --mm:refc.

ringabout avatar Aug 29 '23 01:08 ringabout