Skip to content

tools and CI builds nimsuggest with -d:danger, which hides bugs, maybe explains 100% CPU usage bugs #18385

@timotheecour

Description

@timotheecour

problem 1

nim c -o:bin/nimsuggest -d:danger nimsuggest/nimsuggest.nim
nim r nimsuggest/tester nimsuggest/tests/tmacro_highlight.nim
works

nim c -o:bin/nimsuggest -d:release nimsuggest/nimsuggest.nim
nim r nimsuggest/tester nimsuggest/tests/tmacro_highlight.nim
fails:

==== STDIN ======================================

Test failed: /Users/timothee/git_clone/nim/Nim_prs/nimsuggest/tests/tmacro_highlight.nim
  Expected:  highlight  skMacro 1       6       1
highlight       skType  1       11      6
highlight       skType  1       20      7
highlight       skMacro 3       0       1
highlight       skMacro 3       0       1

  But got:   highlight  skMacro 1       6       1
highlight       skType  1       11      6
highlight       skType  1       20      7
highlight       skMacro 3       0       1
highlight       skMacro 3       0       1
fatal.nim(53)            sysFatal
Error: unhandled exception: value out of range: -1 notin 0 .. 9223372036854775807 [RangeDefect]

stacktrace

nim c -o:bin/nimsuggest --stacktrace -u:nimCompilerStacktraceHints nimsuggest/nimsuggest.nim
nim r nimsuggest/tester nimsuggest/tests/tmacro_highlight.nim

==== STDIN ======================================

Test failed: /Users/timothee/git_clone/nim/Nim_prs/nimsuggest/tests/tmacro_highlight.nim
  Expected:  highlight  skMacro 1       6       1
highlight       skType  1       11      6
highlight       skType  1       20      7
highlight       skMacro 3       0       1
highlight       skMacro 3       0       1

  But got:   highlight  skMacro 1       6       1
highlight       skType  1       11      6
highlight       skType  1       20      7
highlight       skMacro 3       0       1
highlight       skMacro 3       0       1
/Users/timothee/git_clone/nim/Nim_prs/nimsuggest/nimsuggest.nim(651) nimsuggest
/Users/timothee/git_clone/nim/Nim_prs/nimsuggest/nimsuggest.nim(648) handleCmdLine
/Users/timothee/git_clone/nim/Nim_prs/nimsuggest/nimsuggest.nim(548) mainCommand
/Users/timothee/git_clone/nim/Nim_prs/nimsuggest/nimsuggest.nim(497) mainThread
/Users/timothee/git_clone/nim/Nim_prs/nimsuggest/nimsuggest.nim(463) execCmd
/Users/timothee/git_clone/nim/Nim_prs/nimsuggest/nimsuggest.nim(210) execute
/Users/timothee/git_clone/nim/Nim_prs/nimsuggest/nimsuggest.nim(194) executeNoHooks
/Users/timothee/git_clone/nim/Nim_devel/compiler/modules.nim(177) compileProject
/Users/timothee/git_clone/nim/Nim_devel/compiler/modules.nim(97) compileModule
/Users/timothee/git_clone/nim/Nim_devel/compiler/passes.nim(180) processModule
/Users/timothee/git_clone/nim/Nim_devel/compiler/passes.nim(73) processTopLevelStmt
/Users/timothee/git_clone/nim/Nim_devel/compiler/sem.nim(641) myProcess
/Users/timothee/git_clone/nim/Nim_devel/compiler/sem.nim(604) semStmtAndGenerateGenerics
/Users/timothee/git_clone/nim/Nim_devel/compiler/semstmts.nim(2315) semStmt
/Users/timothee/git_clone/nim/Nim_devel/compiler/semexprs.nim(1057) semExprNoType
/Users/timothee/git_clone/nim/Nim_devel/compiler/semexprs.nim(2942) semExpr
/Users/timothee/git_clone/nim/Nim_devel/compiler/semstmts.nim(2257) semStmtList
/Users/timothee/git_clone/nim/Nim_devel/compiler/semexprs.nim(2824) semExpr
/Users/timothee/git_clone/nim/Nim_devel/compiler/semexprs.nim(1040) semDirectOp
/Users/timothee/git_clone/nim/Nim_devel/compiler/semexprs.nim(922) afterCallActions
/Users/timothee/git_clone/nim/Nim_devel/compiler/sem.nim(480) semMacroExpr
/Users/timothee/git_clone/nim/Nim_devel/compiler/vm.nim(2303) evalMacroCall
/Users/timothee/git_clone/nim/Nim_devel/compiler/vmgen.nim(2301) genProc
/Users/timothee/git_clone/nim/Nim_devel/lib/system/fatal.nim(53) sysFatal
Error: unhandled exception: value out of range: -1 notin 0 .. 9223372036854775807 [RangeDefect]

=> c.prc.regInfo.setLen s.offset is the line that raises, s.offset is -1

problem 2

in the stacktrace above, note the 2 different compilers being used:

/Users/timothee/git_clone/nim/Nim_prs/nimsuggest/nimsuggest.nim(194) executeNoHooks
/Users/timothee/git_clone/nim/Nim_devel/compiler/modules.nim(177) compileProject

but this isn't related to problem 1, because with different flags / compiler, i get similar stacktrace as above but with just 1 compiler path eg:

/Users/timothee/git_clone/nim/Nim_prs/nimsuggest/nimsuggest.nim(194) executeNoHooks
/Users/timothee/git_clone/nim/Nim_prs/compiler/modules.nim(177) compileProject

Possible Solution

  • build with -d:release in runCI and koch tools
  • fix corresponding bugs

Additional Information

nim 1.5.1 6387e28

note

if i add doAssert s.offset >= 0, $(s.offset, s) above c.prc.regInfo.setLen s.offset, un-surprisingly, with -d:danger it now does crash with:
Error: unhandled exception: vmgen.nim(2301, 14) s.offset >= 0 (-1, a@452984833) [AssertionDefect]
instead of succeeding, as expected (but still the same bug)

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