Skip to content

Tuple destructor SIGSEGV #24992

Closed
Closed
@Nycto

Description

@Nycto

Nim Version

Nim Compiler Version 2.2.2 [Linux: amd64]
Compiled at 2025-02-06
Copyright (c) 2006-2025 by Andreas Rumpf

git hash: 6c34f62785263ad412f662f3e4e4bf8d8751d113
active boot switches: -d:release

Description

The following code is throwing a null pointer exception

!nim c --gc:arc

type
  Callback*[C] = proc(value: sink C): uint
  Person = object

proc invoke[C](target: Callback[C], values: sink C): uint =
  return target(values)

proc operation(value: sink (Person, string, int)): uint =
  return 123

doAssert invoke(operation, (Person(), "Jack", 25)) == 123

Current Output

Traceback (most recent call last)
/usercode/in.nim(11)     in
/usercode/in.nim(8)      invoke
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Segmentation fault (core dumped)

Expected Output

I expect that code to execute without a SIGSEGV

Known Workarounds

A few different changes will cause this code to work:

  • Removing the sink param
  • Removing any of the tuple parameters
  • Calling the function directly instead of going through the invoke proc

Additional Information

It looks like the error is happening from within the destructor for the tuple, but I might be wrong about that.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions