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

"SIGSEGV" without any "undeclared identifier" error #8011

Closed
chrisokuda opened this issue Jun 10, 2018 · 10 comments

Comments

Projects
None yet
5 participants
@chrisokuda
Copy link
Contributor

commented Jun 10, 2018

When I run the code (https://gitlab.com/snippets/1723320) on my local machine, I get the output:

$> nim c -r -o:bin/run stack.nim  
Hint: used config file '/home/chris/.choosenim/toolchains/nim-0.18.0/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: stack [Processing]
Hint: unittest [Processing]
Hint: macros [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: math [Processing]
Hint: algorithm [Processing]
Hint: streams [Processing]
Hint: times [Processing]
Hint: posix [Processing]
Hint: sets [Processing]
Hint: hashes [Processing]
Hint: os [Processing]
Hint: ospaths [Processing]
Hint: terminal [Processing]
Hint: strformat [Processing]
Hint: unicode [Processing]
Hint: colors [Processing]
Hint: tables [Processing]
Hint: termios [Processing]
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

This occurs in both "stable" and "devel" branches using choosenim:

stable:

$> choosenim stable
$> nim -v
Nim Compiler Version 0.18.0 [Linux: amd64]
Copyright (c) 2006-2018 by Andreas Rumpf

git hash: 855956bf617f68ac0be3717329e9e1181e5dc0c6
active boot switches: -d:release

devel: (as of 2018-06-10T15:00-07:00)

$> choosenim devel
$> nim -v
Nim Compiler Version 0.18.1 [Linux: amd64]
Compiled at 2018-06-10
Copyright (c) 2006-2018 by Andreas Rumpf

active boot switches: -d:release

Expected output would be a message such as test.nim(132, 11) Error: undeclared identifier: 'stack along with the SIGSEGV error.

@2vg

This comment has been minimized.

Copy link
Contributor

commented Jun 11, 2018

SIGSEGV can not be reproduced with the latest devel.

see

@chrisokuda

This comment has been minimized.

Copy link
Contributor Author

commented Jun 11, 2018

@2vg That output is different from mine, mine definitely gives the SIGSEGV error (same output as stable) even on newest devel. I can provide more info if you or anyone else has any ideas.

@2vg

This comment has been minimized.

Copy link
Contributor

commented Jun 11, 2018

For your reference,
I tried it in my Linux environment, but SIGSEGV could not be reproduced. I am using ArchLinux.

@Vindaar

This comment has been minimized.

Copy link
Contributor

commented Jun 11, 2018

It might be interesting to see what the output is, if you compile it with koch, i.e.

./koch temp c <path to stack.nim>

because that should give you a stack trace of the SIGSEGV. Can't reproduce it on my machine either.

I don't use choosenim though, so I don't know whether that also ships koch. If not you can follow the instructions here https://github.com/nim-lang/Nim/#compiling to get the current devel version, including koch manually.

@chrisokuda

This comment has been minimized.

Copy link
Contributor Author

commented Jun 12, 2018

I will try with koch later this week, but I've confirmed that my second laptop also has the same SIGSEGV message without the "undeclared identifier" message. I use the choosenim tool for both right now. If anyone else uses choosenim, can you try this out? I'd like to see the differences between choosenim method of install and others.

I'm very new with this language, so if there's an obvious mechanism in the code to raise the proper compile-time exception, I'd love to hear it so I can investigate why my specific computers don't do it properly.

@ghost

This comment has been minimized.

Copy link

commented Jun 12, 2018

For me, on latest devel, nim c t.nim gives Error: undeclared identifier: 'stack'
But compiling with koch temp, I get -

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(580)             myProcess
sem.nim(548)             semStmtAndGenerateGenerics
semstmts.nim(1882)       semStmt
semexprs.nim(818)        semExprNoType
semexprs.nim(2356)       semExpr
semexprs.nim(1962)       semWhen
semexprs.nim(2433)       semExpr
semstmts.nim(1823)       semStmtList
semexprs.nim(2325)       semExpr
semexprs.nim(802)        semDirectOp
semexprs.nim(699)        afterCallActions
semexprs.nim(31)         semTemplateExpr
sem.nim(404)             semAfterMacroCall
semstmts.nim(1882)       semStmt
semexprs.nim(818)        semExprNoType
semexprs.nim(2433)       semExpr
semstmts.nim(1823)       semStmtList
semexprs.nim(2432)       semExpr
semexprs.nim(2165)       semBlock
semexprs.nim(2433)       semExpr
semstmts.nim(1823)       semStmtList
semexprs.nim(2441)       semExpr
semstmts.nim(271)        semTry
semstmts.nim(108)        semExprBranchScope
semstmts.nim(101)        semExprBranch
semexprs.nim(2433)       semExpr
semstmts.nim(1823)       semStmtList
semexprs.nim(2433)       semExpr
semstmts.nim(1823)       semStmtList
semexprs.nim(2325)       semExpr
semexprs.nim(802)        semDirectOp
semexprs.nim(699)        afterCallActions
semexprs.nim(31)         semTemplateExpr
sem.nim(404)             semAfterMacroCall
semstmts.nim(1882)       semStmt
semexprs.nim(818)        semExprNoType
semexprs.nim(2433)       semExpr
semstmts.nim(1823)       semStmtList
semexprs.nim(2410)       semExpr
semstmts.nim(162)        semIf
semstmts.nim(101)        semExprBranch
semexprs.nim(2433)       semExpr
semstmts.nim(1823)       semStmtList
semexprs.nim(2441)       semExpr
semstmts.nim(271)        semTry
semstmts.nim(108)        semExprBranchScope
semstmts.nim(101)        semExprBranch
semexprs.nim(2433)       semExpr
semstmts.nim(1823)       semStmtList
semexprs.nim(2433)       semExpr
semstmts.nim(1823)       semStmtList
semexprs.nim(2320)       semExpr
semexprs.nim(802)        semDirectOp
semexprs.nim(698)        afterCallActions
sem.nim(451)             semMacroExpr
vm.nim(1905)             evalMacroCall
vm.nim(984)              rawExecute
vm.nim(402)              compile
vmgen.nim(2055)          genProc
vmgen.nim(258)           gen
vmgen.nim(1865)          gen
vmgen.nim(258)           gen
vmgen.nim(1844)          gen
vmgen.nim(352)           genIf
vmgen.nim(1852)          gen
vmgen.nim(312)           genBlock
vmgen.nim(1865)          gen
vmgen.nim(258)           gen
vmgen.nim(1865)          gen
vmgen.nim(258)           gen
vmgen.nim(1852)          gen
vmgen.nim(312)           genBlock
vmgen.nim(1851)          gen
vmgen.nim(306)           genWhile
vmgen.nim(258)           gen
vmgen.nim(1865)          gen
vmgen.nim(258)           gen
vmgen.nim(1865)          gen
vmgen.nim(258)           gen
vmgen.nim(1844)          gen
vmgen.nim(352)           genIf
vmgen.nim(1865)          gen
vmgen.nim(258)           gen
vmgen.nim(1844)          gen
vmgen.nim(352)           genIf
vmgen.nim(1868)          gen
vmgen.nim(258)           gen
vmgen.nim(1813)          gen
vmgen.nim(1082)          genMagic
system.nim(2863)         sysFatal
Error: unhandled exception: value out of range: -1 [RangeError]
@dom96

This comment has been minimized.

Copy link
Member

commented Jun 12, 2018

To rule out choosenim you can run the Nim executable directly:

» choosenim show                                                                                                
   Channel: stable
   Version: 0.18.0
      Path: /Users/dom/.choosenim/toolchains/nim-0.18.0

» /Users/dom/.choosenim/toolchains/nim-0.18.0/bin/nim c stack.nim

But I just figured out how to reproduce this: the filename must be stack.nim.

@dom96 dom96 added the Crash label Jun 12, 2018

@Vindaar

This comment has been minimized.

Copy link
Contributor

commented Jun 13, 2018

Given that value of out range: -1 error in the koch temp output by @nc-x, I had the hunch that this might be related to #8027.
And indeed, after the merge of that PR, the resulting koch error is now (note: only if the file is called stack.nim!):

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
cgen.nim(1379)           myProcess
ccgstmts.nim(1146)       genStmts
ccgexprs.nim(2253)       expr
ccgexprs.nim(2048)       genStmtList
ccgstmts.nim(1146)       genStmts
ccgexprs.nim(2302)       expr
cgen.nim(491)            initLocExpr
ccgexprs.nim(2158)       expr
cgen.nim(888)            genProc
cgen.nim(851)            genProcNoForward
cgen.nim(801)            genProcPrototype
ccgtypes.nim(869)        genProcHeader
ccgtypes.nim(374)        genProcParams
ccgtypes.nim(210)        isInvalidReturnType
ccgtypes.nim(149)        mapType
ast.nim(1293)            lastSon
system.nim(3661)         []
system.nim(2857)         sysFatal
Error: unhandled exception: index out of bounds [IndexError]
FAILURE
@chrisokuda

This comment has been minimized.

Copy link
Contributor Author

commented Jun 13, 2018

@dom96 I tried nim directly from the choosenim directory, no change.
@Vindaar I built nim from source, per the build instructions (devel branch), and ran it on my stack.nim, still the same error as with the choosenim builds.

I'm on Xubuntu 18.04, if that helps.

@dom96

This comment has been minimized.

Copy link
Member

commented Jun 14, 2018

@mcintyrechris you don't need to do anything else. It's a confirmed bug. If you want to workaround it rename your file.

krux02 added a commit to krux02/Nim that referenced this issue Nov 8, 2018

@krux02 krux02 self-assigned this Nov 8, 2018

@Araq Araq closed this in 16353c2 Nov 8, 2018

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.