nim-chronos icon indicating copy to clipboard operation
nim-chronos copied to clipboard

`SIGSEGV` in `asyncTest`-derived scenario (also, in `asyncTest`)

Open tersec opened this issue 4 months ago • 5 comments

import chronos    # only depends on asyncloop's transitive closure

proc t(): Future[int] {.async: (raw: true, raises: [ValueError]).} =
  var retFuture = newFuture[int]("")
  retFuture.fail(newException(ValueError, ""))
  return retFuture

proc m(transp: int): Future[void] {.async: (raw: true, raises: []).} =
  var retFuture = newFuture[void]("")
  retFuture.complete()
  return retFuture

proc p(self: int) {.async.} = await self.m()

try:
  defer: waitFor p(0)    # teardown
  waitFor((proc() {.async.} = discard await t())())  # asyncTest
except CatchableError:
  discard

Across all of Nim 1.6 refc and Nim 2.0 and devel refc and ORC:

rm ~/.cache/nim/ -rf && ~/nim16/bin/nim c -r /tmp/w; ~/nim20/bin/nim c -r --hints:off --mm:refc /tmp/w; ~/nim20/bin/nim c -r --hints:off --mm:orc /tmp/w; ~/nimdevel/bin/nim c -r --hints:off --mm:refc /tmp/w; ~/nimdevel/bin/nim c -r --hints:off --mm:orc /tmp/w
Traceback (most recent call last)
/tmp/w.nim(16)   w
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Segmentation fault
Error: execution of an external program failed: '/tmp/w'
Traceback (most recent call last)
/tmp/w.nim(16)   w
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Segmentation fault
Error: execution of an external program failed: '/tmp/w'
Traceback (most recent call last)
.nimble/pkgs2/chronos-4.0.0-2b7b9c774b0fb8c3b1d415da6148c8973c4ba81c/chronos/internal/asyncfutures.nim(217) w
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Segmentation fault
Error: execution of an external program failed: '/tmp/w'
Traceback (most recent call last)
/tmp/w.nim(16)   w
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Segmentation fault
Error: execution of an external program failed: '/tmp/w`
Traceback (most recent call last)
.nimble/pkgs2/chronos-4.0.0-2b7b9c774b0fb8c3b1d415da6148c8973c4ba81c/chronos/internal/asyncfutures.nim(217) hmm
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Segmentation fault
Error: execution of an external program failed: '/tmp/w'

Nim versions:

Nim Compiler Version 1.6.19 [Linux: amd64]
Compiled at 2024-03-03
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 51c86fdae77b6ebd9c9caf4924ec1edfe7883933
active boot switches: -d:release
Nim Compiler Version 2.0.3 [Linux: amd64]
Compiled at 2024-03-03
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: e03667e92040bae8f8a7f817679a1abb4d19f4eb
active boot switches: -d:release
Nim Compiler Version 2.1.1 [Linux: amd64]
Compiled at 2024-03-03
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 1e7ca2dc789eafccdb44304f7e42206c3702fc13
active boot switches: -d:release

And this does trigger with the Chronos commit in nimbus-eth2, as well as the one one gets from cloning this repo in a default way.

tersec avatar Mar 03 '24 18:03 tersec