nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.54k stars 1.47k forks source link

compiler error: unhandled exception: index out of bounds, the container is empty [IndexError] #17704

Open stefantalpalaru opened 3 years ago

stefantalpalaru commented 3 years ago

replication instructions

git clone https://github.com/status-im/nimbus-eth2.git
cd nimbus-eth2
git checkout unstable
make -j8 update
# replace with your own Nim build from the "version-1-2" branch
PATH="/src/77_DLD/CODE/00_github/Nim/bin/:${PATH}"; rm -rf nimcache; make -j8 USE_SYSTEM_NIM=1 V=1 all_tests

stack trace

/mnt/sda3/storage/CODE/00_github/Nim/compiler/nim.nim(118) nim
/mnt/sda3/storage/CODE/00_github/Nim/compiler/nim.nim(95) handleCmdLine
/mnt/sda3/storage/CODE/00_github/Nim/compiler/cmdlinehelper.nim(77) loadConfigsAndRunMainCommand
/mnt/sda3/storage/CODE/00_github/Nim/compiler/main.nim(193) mainCommand
/mnt/sda3/storage/CODE/00_github/Nim/compiler/main.nim(95) commandCompileToC
/mnt/sda3/storage/CODE/00_github/Nim/compiler/modules.nim(143) compileProject
/mnt/sda3/storage/CODE/00_github/Nim/compiler/modules.nim(84) compileModule
/mnt/sda3/storage/CODE/00_github/Nim/compiler/passes.nim(216) processModule
/mnt/sda3/storage/CODE/00_github/Nim/compiler/passes.nim(86) processTopLevelStmt
/mnt/sda3/storage/CODE/00_github/Nim/compiler/sem.nim(604) myProcess
/mnt/sda3/storage/CODE/00_github/Nim/compiler/sem.nim(572) semStmtAndGenerateGenerics
/mnt/sda3/storage/CODE/00_github/Nim/compiler/semstmts.nim(2308) semStmt
/mnt/sda3/storage/CODE/00_github/Nim/compiler/semexprs.nim(1006) semExprNoType
/mnt/sda3/storage/CODE/00_github/Nim/compiler/semexprs.nim(2801) semExpr
/mnt/sda3/storage/CODE/00_github/Nim/compiler/importer.nim(218) evalImport
/mnt/sda3/storage/CODE/00_github/Nim/compiler/importer.nim(188) impMod
/mnt/sda3/storage/CODE/00_github/Nim/compiler/importer.nim(158) myImportModule
/mnt/sda3/storage/CODE/00_github/Nim/compiler/modules.nim(98) importModule
/mnt/sda3/storage/CODE/00_github/Nim/compiler/modules.nim(84) compileModule
/mnt/sda3/storage/CODE/00_github/Nim/compiler/passes.nim(210) processModule
/mnt/sda3/storage/CODE/00_github/Nim/compiler/passes.nim(86) processTopLevelStmt
/mnt/sda3/storage/CODE/00_github/Nim/compiler/sem.nim(604) myProcess
/mnt/sda3/storage/CODE/00_github/Nim/compiler/sem.nim(572) semStmtAndGenerateGenerics
/mnt/sda3/storage/CODE/00_github/Nim/compiler/semstmts.nim(2308) semStmt
/mnt/sda3/storage/CODE/00_github/Nim/compiler/semexprs.nim(1006) semExprNoType
/mnt/sda3/storage/CODE/00_github/Nim/compiler/semexprs.nim(2768) semExpr
/mnt/sda3/storage/CODE/00_github/Nim/compiler/semstmts.nim(2248) semStmtList
/mnt/sda3/storage/CODE/00_github/Nim/compiler/semexprs.nim(2678) semExpr
/mnt/sda3/storage/CODE/00_github/Nim/compiler/semexprs.nim(987) semDirectOp
/mnt/sda3/storage/CODE/00_github/Nim/compiler/semexprs.nim(836) semOverloadedCallAnalyseEffects
/mnt/sda3/storage/CODE/00_github/Nim/compiler/semcall.nim(566) semOverloadedCall
/mnt/sda3/storage/CODE/00_github/Nim/compiler/semcall.nim(527) semResolvedCall
/mnt/sda3/storage/CODE/00_github/Nim/compiler/seminst.nim(400) generateInstance
/mnt/sda3/storage/CODE/00_github/Nim/compiler/seminst.nim(148) instantiateBody
/mnt/sda3/storage/CODE/00_github/Nim/compiler/semexprs.nim(1764) semProcBody
/mnt/sda3/storage/CODE/00_github/Nim/compiler/semexprs.nim(2768) semExpr
/mnt/sda3/storage/CODE/00_github/Nim/compiler/semstmts.nim(2248) semStmtList
/mnt/sda3/storage/CODE/00_github/Nim/compiler/semexprs.nim(2791) semExpr
/mnt/sda3/storage/CODE/00_github/Nim/compiler/semtempl.nim(675) semTemplateDef
/mnt/sda3/storage/CODE/00_github/Nim/compiler/semtempl.nim(581) semTemplBody
/mnt/sda3/storage/CODE/00_github/Nim/compiler/semtempl.nim(349) semTemplBodySons
/mnt/sda3/storage/CODE/00_github/Nim/compiler/semtempl.nim(382) semTemplBody
/mnt/sda3/storage/CODE/00_github/Nim/compiler/semtempl.nim(114) semMixinStmt
/mnt/sda3/storage/CODE/00_github/Nim/compiler/lookups.nim(51) considerQuotedIdent
/mnt/sda3/storage/CODE/00_github/Nim/lib/system/fatal.nim(49) sysFatal
Error: unhandled exception: index out of bounds, the container is empty [IndexError]
make: *** [Makefile:232: all_tests] Error 1
$ nim -v
Nim Compiler Version 1.2.11 [Linux: amd64]
Compiled at 2021-04-12
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: fe8b84496ffe40cd86b9db688cf5494187b437e4
active boot switches:
timotheecour commented 3 years ago

please minimize and test against devel (like all other bug reports)

narimiran commented 3 years ago

test against devel

They (Status) use Nim 1.2.x and this was caught as a part of the testing of 1.2.12 RC.

narimiran commented 3 years ago

Fixed by https://github.com/nim-lang/Nim/commit/6238f2ee1e83c83f6e5d3f923c118ddd536ef96d, will be available in the nightlies tomorrow morning.

@stefantalpalaru In the mean time, you can checkout version-1-2 branch and test it. I've tested locally, and for me the command you posted in OP works now.

timotheecour commented 3 years ago

this will probably unblock OP, but before closing this issue, we should still minimize and see whether root problem occurs on devel, because based on https://github.com/nim-lang/Nim/commit/6238f2ee1e83c83f6e5d3f923c118ddd536ef96d it's likely that https://github.com/nim-lang/Nim/pull/17255 would cause the problem on devel.

stefantalpalaru commented 3 years ago

you can checkout version-1-2 branch and test it

Yes, it works now. Thanks!

we should still minimize

Easier said than done.

see whether root problem occurs on devel

I can't compile Nimbus-eth2 programs with Nim devel. First it fails with:

/mnt/sde1/storage/nimbus-eth2/vendor/nim-libp2p/libp2p/protocols/pubsub/gossipsub.nim(297, 38) Error: 't' is of type <lent string> which cannot be captured as it would violate memory safety, declared here: /mnt/sde1/storage/nimbus-eth2/vendor/nim-libp2p/libp2p/protocols/pubsub/gossipsub.nim(290, 11); using '-d:nimWorkaround14447' helps in some cases then, after adding '-d:nimWorkaround14447', it fails in another way:

/mnt/sde1/storage/nimbus-eth2/beacon_chain/networking/eth2_network.nim(1283, 25) template/generic instantiation from here /mnt/sde1/storage/nimbus-eth2/beacon_chain/networking/eth2_network.nim(1362, 29) Error: implementSendProcBody sendProc can raise an unlisted exception: Exception