Skip to content

crash when calling await within a try block within an except block #14714

Open
@onqtam

Description

@onqtam

Example

import asyncdispatch

proc test() {.gcsafe, async.} =
  try:
    await sleepAsync(1000)
    return
  except CatchableError as err:
    echo err.msg

var mrRuntime = true
try:
  if mrRuntime:
    raise newException(CatchableError, "Not implemented")
except CatchableError as err:
  echo err.msg
  waitFor test() # if this is in the `except` block it crashes - otherwise (unindent) it's fine

Current Output

Not implemented
Traceback (most recent call last)
/home/onqtam/a.nim(16)   a
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

Expected Output

Not implemented

Additional Information

This was happening with previous versions of the compiler as well. Note that if you move waitFor test() outside of the except block it will no longer crash.

I haven't looked if this exact bug has already been reported.

$ nim -v
Nim Compiler Version 1.2.2 [Linux: amd64]
Compiled at 2020-06-18
Copyright (c) 2006-2020 by Andreas Rumpf

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    AsyncEverything related to Nim's async

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions