I made a simple program that launches a worker thread that is supposed to make requests with puppy and send the response down a channel:
import puppy
type
Action = object
request: Request
response: ptr Channel[Response]
Client = ref object
requestThread: Thread[Client]
requestReady: ptr Channel[bool]
action: ptr Channel[Action]
proc recvAction(client: Client) {.thread.} =
client.requestReady[].send(true)
while true:
let action = client.action[].recv()
action.response[].send(fetch(action.request))
proc start*(client: var Client) =
client.requestReady = cast[ptr Channel[bool]](
allocShared0(sizeof(Channel[bool]))
)
client.action = cast[ptr Channel[Action]](
allocShared0(sizeof(Channel[Action]))
)
client.requestReady[].open()
client.action[].open()
createThread(client.requestThread, recvAction, client)
discard client.requestReady[].recv() # wait for thread to be ready
var c = Client()
start(c)
let res = cast[ptr Channel[Response]](
allocShared0(sizeof(Channel[Response]))
)
res[].open()
c.action[].send(Action(request: Request(url: parseUrl("http://tired.com"), verb: "get"), response: res))
echo res[].recv()[]
If i save that to chtest.nim and run with nim c -r --threads:on --gc:orc chtest.nim I get a SIGSEGV:
/home/sekao/.choosenim/toolchains/nim-#version-1-6/lib/pure/strutils.nim(368) fetch
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
But running it via the default GC works: nim c -r --threads:on chtest.nim
This happens with nim 1.6 RC2 and with nim 1.4.8.
I don't think it's the same as #11 because it happens not just on linux, but mac OS as well. But the error message is similar so maybe it is. I'm guessing it's not specificially a problem with puppy, but i haven't been able to repro the error when sending other data types through a channel :/
I made a simple program that launches a worker thread that is supposed to make requests with puppy and send the response down a channel:
If i save that to
chtest.nim
and run withnim c -r --threads:on --gc:orc chtest.nim
I get a SIGSEGV:But running it via the default GC works:
nim c -r --threads:on chtest.nim
This happens with nim 1.6 RC2 and with nim 1.4.8.
I don't think it's the same as #11 because it happens not just on linux, but mac OS as well. But the error message is similar so maybe it is. I'm guessing it's not specificially a problem with puppy, but i haven't been able to repro the error when sending other data types through a channel :/