fixes #2854
This commit is contained in:
parent
706080dcbd
commit
a730a974ed
2 changed files with 27 additions and 1 deletions
|
|
@ -1346,7 +1346,7 @@ proc propagateToOwner*(owner, elem: PType) =
|
||||||
owner.flags.incl tfHasAsgn
|
owner.flags.incl tfHasAsgn
|
||||||
|
|
||||||
if owner.kind notin {tyProc, tyGenericInst, tyGenericBody,
|
if owner.kind notin {tyProc, tyGenericInst, tyGenericBody,
|
||||||
tyGenericInvocation}:
|
tyGenericInvocation, tyPtr}:
|
||||||
let elemB = elem.skipTypes({tyGenericInst})
|
let elemB = elem.skipTypes({tyGenericInst})
|
||||||
if elemB.isGCedMem or tfHasGCedMem in elemB.flags:
|
if elemB.isGCedMem or tfHasGCedMem in elemB.flags:
|
||||||
# for simplicity, we propagate this flag even to generics. We then
|
# for simplicity, we propagate this flag even to generics. We then
|
||||||
|
|
|
||||||
26
tests/parallel/tptr_to_ref.nim
Normal file
26
tests/parallel/tptr_to_ref.nim
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
# bug #2854
|
||||||
|
|
||||||
|
import locks, threadpool, osproc
|
||||||
|
|
||||||
|
const MAX_WORKERS = 10
|
||||||
|
|
||||||
|
type
|
||||||
|
Killer = object
|
||||||
|
lock: Lock
|
||||||
|
bailed {.guard: lock.}: bool
|
||||||
|
processes {.guard: lock.}: array[0..MAX_WORKERS-1, foreign ptr Process]
|
||||||
|
|
||||||
|
template hold(lock: Lock, body: stmt) =
|
||||||
|
lock.acquire
|
||||||
|
defer: lock.release
|
||||||
|
{.locks: [lock].}:
|
||||||
|
body
|
||||||
|
|
||||||
|
proc initKiller*(): Killer =
|
||||||
|
initLock(result.lock)
|
||||||
|
result.lock.hold:
|
||||||
|
result.bailed = false
|
||||||
|
for i, _ in result.processes:
|
||||||
|
result.processes[i] = nil
|
||||||
|
|
||||||
|
var killer = initKiller()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue