nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.43k stars 1.47k forks source link

gc:arc cannot fully support threadpool with FlowVar #13781

Closed khchen closed 1 year ago

khchen commented 4 years ago

Example

import threadpool, os

proc thread(): string =
  os.sleep(1000)
  return "ok"

var fv = spawn thread()
sync()
echo ^fv

Current Output

Error: cannot bind another '=destroy' to: FlowVarObj; previous declaration was constructed here implicitly: d:\nim\lib\pure\concurrency\threadpool.nim(211, 48)

Expected Output

ok

$ nim -v Nim Compiler Version 1.1.1 [Windows: amd64] Compiled at 2020-03-27```

cooldome commented 4 years ago

I do have a fix for this one

diegomrsantos commented 1 year ago

Seems there is a regression. Running the same code as reported outputs the following:

Current Output

ok
Traceback (most recent call last)
.choosenim/toolchains/nim-#devel/lib/pure/concurrency/threadpool.nim(216) test
.choosenim/toolchains/nim-#devel/lib/system/orc.nim(486) nimDecRefIsLastCyclicDyn
.choosenim/toolchains/nim-#devel/lib/system/orc.nim(469) rememberCycle
.choosenim/toolchains/nim-#devel/lib/system/orc.nim(147) unregisterCycle
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

Nim Compiler Version 1.7.3 [MacOSX: amd64] Compiled at 2022-11-09 Copyright (c) 2006-2022 by Andreas Rumpf

git hash: cdb136f58545009d2e38e5f1c4822bcc6dc7df83 active boot switches: -d:release

Araq commented 1 year ago

Report it properly. A test program that fails, a new issue, more information, things like that.

diegomrsantos commented 1 year ago

I can create a new issue if that's better, but I used the same code as initially reported and posted the current output.

Araq commented 1 year ago

Ah ok.

ringabout commented 1 year ago

I can create a new issue if that's better, but I used the same code as initially reported and posted the current output.

Duplicate of https://github.com/nim-lang/Nim/issues/14901