Skip to content

cdt, crash with --gc:arc, works fine with default gc #12978

@StefanSalewski

Description

@StefanSalewski

Here is the fully condensed code as requested:

Example

type
  Vector2* = object of RootObj
    x*, y*: float

type
  Vertex* = ref object
    point*: Vector2

proc newVertex*(p: Vector2): Vertex =
  return Vertex(point: p)

proc createVertex*(p: Vector2): Vertex =
  result = newVertex(p)

proc p =
  var x = Vector2(x: 1, y: 2)
  discard createVertex(x)
  echo "OK"

p()

Current Output

$ nim c -r t.nim 
Hint: used config file '/home/stefan/Nim/config/nim.cfg' [Conf]
Hint: used config file '/home/stefan/Nim/config/config.nims' [Conf]
Hint: operation successful (7695 lines compiled; 0.018 sec total; 11.562MiB peakmem; Debug Build) [SuccessX]
Hint: /tmp/hhh/t  [Exec]
OK
stefan@nuc /tmp/hhh $ nim c --gc:arc -r t.nim 
Hint: used config file '/home/stefan/Nim/config/nim.cfg' [Conf]
Hint: used config file '/home/stefan/Nim/config/config.nims' [Conf]
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: t [Processing]
/home/stefan/Nim/lib/system/excpt.nim(464, 23) Hint: passing 'currException' to a sink parameter introduces an implicit copy; use 'move(currException)' to prevent it [Performance]
CC: stdlib_io.nim
CC: stdlib_system.nim
CC: t.nim
Hint:  [Link]
Hint: operation successful (19548 lines compiled; 0.340 sec total; 24.516MiB peakmem; Debug Build) [SuccessX]
Hint: /tmp/hhh/t  [Exec]
Traceback (most recent call last)
/tmp/hhh/t.nim(20)       t
/tmp/hhh/t.nim(17)       p
/tmp/hhh/t.nim(13)       createVertex
/tmp/hhh/t.nim(10)       newVertex
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Error: execution of an external program failed: '/tmp/hhh/t '

Expected Output

Consistency at least

Possible Solution

  • fix it

Additional Information

$ nim -v
Nim Compiler Version 1.1.1 [Linux: amd64]
Compiled at 2019-12-25
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: 649bf326bfc6b4eb983403d850b1dcfc0cc854ae
active boot switches: -d:release

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