Files
Nim/tests/async
Andreas Rumpf e927887b7e fix SIGSEGV on refc: genGenericAsgn must deep-copy from static data (#26160)
Supersedes #26120 (https://github.com/nim-lang/Nim/pull/26120), which
fixed the reported case but left the `tfShallow` half of the same
condition open.

Since #25860 array literals are materialized into temporaries so that
`lent` results keep valid backing storage. In an async proc such a
temporary is lifted into the closure environment, and the environment is
filled with an `nkFastAsgn`, i.e. without `needToCopy`. `genGenericAsgn`
then emitted `genericShallowAssign` from the static const array, and for
the `string` elements that ends in `unsureAsgnRef` ->
`incRef(usrToCell(literal))` on memory that has no GC header:

  proc f() {.async.} =
    for ip in ["::1", "2001:db8::", "::"]:
      await sleepAsync(1)

`OnStatic` sources must therefore always take the `genericAssign` path.
Note that the guard has to dominate the `tfShallow` test as well, not
just the `needToCopy` one: a `{.shallow.}` destination assigned from a
`const` crashes in exactly the same way. This is the precedence
`genOptAsgnTuple` and `genOptAsgnObject` already use, so
`genGenericAsgn` now agrees with its two siblings instead of
contradicting them.

refc only; the other GCs do not reference count in `unsureAsgnRef`.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-02 22:16:57 +08:00
..
2021-09-19 23:35:50 +02:00
2018-12-11 21:23:22 +01:00
2020-12-28 14:13:21 +01:00
2026-07-06 14:00:43 +02:00
2020-08-08 07:24:54 +02:00
2020-11-02 14:17:09 +01:00
2026-06-13 11:06:51 +08:00
2017-05-16 22:09:19 +02:00
2016-09-07 12:19:06 +03:00
2018-12-11 21:23:22 +01:00
2018-12-11 21:23:21 +01:00
2018-12-11 21:23:22 +01:00
2018-11-07 15:22:02 +01:00
2020-03-30 13:18:12 +02:00
2016-10-20 15:20:27 +02:00
2020-03-30 13:18:12 +02:00
2018-04-30 02:52:58 +02:00
2014-09-09 01:17:07 +01:00
2016-01-11 11:11:44 +01:00
2020-03-30 13:18:12 +02:00
2016-09-17 13:22:04 +02:00
2016-07-08 10:34:12 +02:00