Skip to content

SIGSEGV regression from Nim v2.2.4 to v2.2.6/devel with closure iteratures #25261

@tersec

Description

@tersec

Nim Version

No SIGSEGV:

Nim Compiler Version 2.2.4 [Linux: amd64]
Compiled at 2025-11-03
Copyright (c) 2006-2025 by Andreas Rumpf

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

SIGSEGV:

Nim Compiler Version 2.2.6 [Linux: amd64]
Compiled at 2025-11-05
Copyright (c) 2006-2025 by Andreas Rumpf

git hash: ab00c56904e3126ad826bb520d243513a139436a
active boot switches: -d:release
Nim Compiler Version 2.3.1 [Linux: amd64]
Compiled at 2025-11-05
Copyright (c) 2006-2025 by Andreas Rumpf

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

Description

iterator y(): int {.closure.} =
  try:
    try:
      raise newException(CatchableError, "")
    except CatchableError:
      return
    yield 0
  finally:
    discard

let w = y
discard w()

Current Output

/tmp/m.nim(7, 5) Warning: unreachable code after 'return' statement or '{.noReturn.}' proc [UnreachableCode]
CC: system/exceptions.nim
CC: std/private/digitsutils.nim
CC: system/dollars.nim
CC: system.nim
CC: m.nim
Hint:  [Link]
Hint: mm: orc; threads: on; opt: none (DEBUG BUILD, `-d:release` generates faster code)
28942 lines; 0.491s; 31.199MiB peakmem; proj: /tmp/m.nim; out: /tmp/m [SuccessX]
Hint: /tmp/m [Exec]
Traceback (most recent call last)
/tmp/m.nim(12)           m
/tmp/m.nim(1)            y
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Segmentation fault
Error: execution of an external program failed: '/tmp/m'

Expected Output

No SIGSEGV

Known Workarounds

No response

Additional Information

No response

Metadata

Metadata

Assignees

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