Skip to content

regression from refc to ORC in stack usage of data specified to be entirely on heap #25688

@tersec

Description

@tersec

Nim Version

Nim Compiler Version 2.2.8 [Linux: amd64]
Compiled at 2026-04-01
Copyright (c) 2006-2026 by Andreas Rumpf

git hash: 4f500679b196fad944caa50a753f5bbfaefda001
active boot switches: -d:release
Nim Compiler Version 2.2.9 [Linux: amd64]
Compiled at 2026-04-01
Copyright (c) 2006-2026 by Andreas Rumpf

git hash: 03df884f023dd2c9c5a5121de2e4b80bc17b1b18
active boot switches: -d:release
Nim Compiler Version 2.3.1 [Linux: amd64]
Compiled at 2026-04-01
Copyright (c) 2006-2026 by Andreas Rumpf

git hash: 9c07bb94c1eb170f3b358043cff40d12d7fcd5ae
active boot switches: -d:release

Description

type
  S = object
    p: array[5 * 1024 * 1024, byte]
    q: seq[byte]

  F = object
    case k: bool
    of false: a: S
    of true:  b: S

proc u(x: S): S = discard

proc m(v: var F) =
  case v.k
  of false:
    let r = (ref F)(k: true)
    r[].b = u(v.a)
    v = move(r[])
  of true: discard

let s = (ref F)(k: false)
m(s[])

Current Output

......................................................................
CC: system/exceptions.nim
CC: std/private/digitsutils.nim
CC: system/dollars.nim
CC: system.nim
CC: d.nim
Hint:  [Link]
Hint: mm: orc; threads: on; opt: none (DEBUG BUILD, `-d:release` generates faster code)
29397 lines; 0.513s; 38.055MiB peakmem; proj: /tmp/d.nim; out: /tmp/d [SuccessX]
Hint: /tmp/d [Exec]
Segmentation fault
Error: execution of an external program failed: '/tmp/d'

Expected Output

No segmentation fault

Known Workarounds

No response

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions