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

ICE when trying to repr nnkMutableTy in macro #15751

Closed
Vindaar opened this issue Oct 27, 2020 · 2 comments · Fixed by #23372
Closed

ICE when trying to repr nnkMutableTy in macro #15751

Vindaar opened this issue Oct 27, 2020 · 2 comments · Fixed by #23372
Assignees

Comments

@Vindaar
Copy link
Contributor

Vindaar commented Oct 27, 2020

Had a bug that appeared in a test case of shell a few months ago. Finally took a look at what's going on.
I have a test case that has a --out in its argument. It seems that at some point trying to repr a nnkMutableTy (the node of out, at least nowadays) became an internal compiler error.

Example

import macros

macro print(n: untyped): untyped =
  echo n.treeRepr # works
  echo n.repr # sigsegv

print:
  out

Current Output

StmtList
  MutableTy
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

Expected Output

StmtList
  MutableTy
out # or maybe something else, but no ICE :)

Additional Information

I'm on current devel right now and the problem persists.

Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2020-10-27
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: 0fb878324eeb39a4707be5ab0fd6ad8412950b78
active boot switches: -d:release -d:danger

I definitely know that it worked in the past. I don't have a specific commit, but the first failure on Travis was (oh my god, time flies) April 20.

Output of koch temp:

StmtList
  MutableTy
/home/basti/src/nim/nim_git_repo/compiler/nim.nim(118) nim
/home/basti/src/nim/nim_git_repo/compiler/nim.nim(83) handleCmdLine
/home/basti/src/nim/nim_git_repo/compiler/main.nim(240) mainCommand
/home/basti/src/nim/nim_git_repo/compiler/main.nim(205) compileToBackend
/home/basti/src/nim/nim_git_repo/compiler/main.nim(86) commandCompileToC
/home/basti/src/nim/nim_git_repo/compiler/modules.nim(158) compileProject
/home/basti/src/nim/nim_git_repo/compiler/modules.nim(94) compileModule
/home/basti/src/nim/nim_git_repo/compiler/passes.nim(196) processModule
/home/basti/src/nim/nim_git_repo/compiler/passes.nim(73) processTopLevelStmt
/home/basti/src/nim/nim_git_repo/compiler/sem.nim(601) myProcess
/home/basti/src/nim/nim_git_repo/compiler/sem.nim(569) semStmtAndGenerateGenerics
/home/basti/src/nim/nim_git_repo/compiler/semstmts.nim(2294) semStmt
/home/basti/src/nim/nim_git_repo/compiler/semexprs.nim(1028) semExprNoType
/home/basti/src/nim/nim_git_repo/compiler/semexprs.nim(2838) semExpr
/home/basti/src/nim/nim_git_repo/compiler/semstmts.nim(2236) semStmtList
/home/basti/src/nim/nim_git_repo/compiler/semexprs.nim(2726) semExpr
/home/basti/src/nim/nim_git_repo/compiler/semexprs.nim(1010) semDirectOp
/home/basti/src/nim/nim_git_repo/compiler/semexprs.nim(892) afterCallActions
/home/basti/src/nim/nim_git_repo/compiler/sem.nim(471) semMacroExpr
/home/basti/src/nim/nim_git_repo/compiler/vm.nim(2291) evalMacroCall
/home/basti/src/nim/nim_git_repo/compiler/vm.nim(1432) rawExecute
/home/basti/src/nim/nim_git_repo/compiler/renderer.nim(1629) renderTree
/home/basti/src/nim/nim_git_repo/compiler/renderer.nim(662) gstmts
/home/basti/src/nim/nim_git_repo/compiler/renderer.nim(574) gsub
/home/basti/src/nim/nim_git_repo/compiler/renderer.nim(1619) gsub
/home/basti/src/nim/nim_git_repo/compiler/msgs.nim(585) internalErrorImpl
/home/basti/src/nim/nim_git_repo/compiler/msgs.nim(525) liMessage
/home/basti/src/nim/nim_git_repo/compiler/msgs.nim(281) toFileLineCol
/home/basti/src/nim/nim_git_repo/compiler/msgs.nim(266) toMsgFilename
/home/basti/src/nim/nim_git_repo/compiler/msgs.nim(249) toFilenameOption
/home/basti/src/nim/nim_git_repo/compiler/msgs.nim(200) toFullPath
/home/basti/src/nim/nim_git_repo/lib/system/fatal.nim(49) sysFatal
Error: unhandled exception: index out of bounds, the container is empty [IndexDefect]
FAILURE
@Clyybber
Copy link
Contributor

Clyybber commented Oct 27, 2020

Heh, I had the same error a few days ago, the issue is that the renderer is using internalError but only has an empty config created with newPartialConfigRef which makes internalError crash while accessing the fileInfos for printiing.

The other issue that actually causes the call to internalError is that this node kind simply isn't handled yet in the renderer :D

@metagn
Copy link
Collaborator

metagn commented Oct 5, 2023

Is this still an issue?

@metagn metagn added the Easy label Oct 5, 2023
@ringabout ringabout self-assigned this Feb 5, 2024
ringabout added a commit that referenced this issue Mar 6, 2024
ringabout added a commit that referenced this issue Mar 6, 2024
narimiran pushed a commit that referenced this issue May 21, 2024
closes #15751

(cherry picked from commit a2584c7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants