Skip to content

memory leak with nested Exceptions via function #25037

@inv2004

Description

@inv2004

Nim Version

Version 2.2.4 [Linux: amd64]
also Version 2.3.1 [Linux: amd64]

Description

The issues #22398 looks still actual but with some small changes:

type InfoError* = object of ValueError
  info*: string

proc newInfoError(info: string, parent: ref Exception): ref InfoError =
  newException(InfoError, info, parent)

proc main() =
  while true:
    try:
      try:
        raise newException(ValueError, "msg")
      except:
        raise newInfoError("info", getCurrentException())                # leak
        # raise newException(InfoError, "info", getCurrentException())   # no leak
    except:
      discard
    echo getOccupiedMem()

main()

Current Output

increasing getOccupiedMem

Expected Output

stable getOccupiedMem

Known Workarounds

No response

Additional Information

related to #22398

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions