SIGSEGV: Illegal storage access. (Attempt to read from nil?)
lost22git opened this issue · 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
I just got the exact same error on Arch using siege
for concurrency testing - same nim + prologue versions, and same test code 😆
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).
I also noticed the (per request) DEBUG log does not show on nim 2.0 either - only the boot up message does.
These versions do not produce the issue:
requires "nim == 1.6.14"
requires "prologue == 0.6.4"
https://github.com/nim-lang/Nim/issues?q=is%3Aissue+is%3Aopen+sigsegv+ - looks like a lot of this in 2.0 release usage.
Maybe helpful to prologue, httpbeast is having a similar issue: nim-lang/Nim#21422
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.
I updated httpx issue here: ringabout/httpx#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.
Another workaround is to use --mm:refc
.