Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug mode compiler crash when executing some compile time code #8199

jangko opened this issue Jul 3, 2018 · 2 comments


None yet
4 participants
Copy link

commented Jul 3, 2018

const rangesGCHoldEnabled = not defined(rangesDisableGCHold)

  # A view into immutable array
  Range* {.shallow.} [T] = object
    when rangesGCHoldEnabled:
      gcHold: seq[T]
    start: ptr T
    mLen: int32
  BytesRange* = Range[byte]
  NibblesRange* = object
    bytes: BytesRange

  zeroBytesRange* = BytesRange()

proc initNibbleRange*(bytes: BytesRange): NibblesRange =
  result.bytes = bytes

  zeroNibblesRange* = initNibbleRange(zeroBytesRange)

error messages:

nim.nim(133)             nim
nim.nim(97)              handleCmdLine
main.nim(162)            mainCommand
main.nim(73)             commandCompileToC
modules.nim(124)         compileProject
modules.nim(71)          compileModule
passes.nim(194)          processModule
passes.nim(103)          processTopLevelStmt
sem.nim(592)             myProcess
sem.nim(560)             semStmtAndGenerateGenerics
semstmts.nim(1893)       semStmt
semexprs.nim(910)        semExprNoType
semexprs.nim(2525)       semExpr
semstmts.nim(597)        semConst
sem.nim(350)             semConstExpr
vm.nim(1834)             evalConstExpr
vm.nim(1830)             evalConstExprAux
vm.nim(571)              rawExecute
vm.nim(208)              writeField
system.nim(2877)         sysFatal
Error: unhandled exception: intVal is not accessible [FieldError]

nim version:

PS F:\projects\bug> nim -v
Nim Compiler Version 0.18.1 [Windows: amd64]
Compiled at 2018-07-03
Copyright (c) 2006-2018 by Andreas Rumpf

git hash: 681d8e0749fd4374c3cc904ef27a5f600f3c4bb5
active boot switches:

if the compiler compiled with -d:release, all is ok.

@dom96 dom96 added VM Crash labels Jul 3, 2018


This comment has been minimized.

Copy link

commented Jul 3, 2018

if the compiler compiled with -d:release, all is ok.

Ha, you wish. ;-)


This comment has been minimized.

Copy link

commented Jul 3, 2018

The symbol .position for gcHold and start is 0, that's why the VM kicks the bucket when the object fields are accessed.

The problem lies in semRecordNodeAux and is due to the presence of the generic argument T, it's not much of a VM problem,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.