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

Nimsuggest crashes when run without a backend specified #117

Closed
liquidev opened this issue Oct 16, 2020 · 7 comments · Fixed by nim-lang/Nim#15602
Closed

Nimsuggest crashes when run without a backend specified #117

liquidev opened this issue Oct 16, 2020 · 7 comments · Fixed by nim-lang/Nim#15602

Comments

@liquidev
Copy link

liquidev commented Oct 16, 2020

Happens on this file, I haven't been able to reproduce it on a smaller example but that shouldn't matter.

Since Nim 1.4 nimsuggest hits an assertion when run like this:

❯ nimsuggest tests/tchipmunk.nim
Hint: used config file '/home/daknus/.choosenim/toolchains/nim-1.4.0/config/nim.cfg' [Conf]
Hint: used config file '/home/daknus/.choosenim/toolchains/nim-1.4.0/config/config.nims' [Conf]
Hint: used config file '/home/daknus/.config/nim/nim.cfg' [Conf]
Hint: used config file '/home/daknus/.config/nim/config.nims' [Conf]
Hint: used config file '/home/daknus/Coding/Nim/rapid/tests/config.nims' [Conf]
fatal.nim(49)            sysFatal
Error: unhandled exception: extccomp.nim(631, 31) `false`  [AssertionDefect]

It doesn't crash however when the backend is specified explicitly:

❯ nimsuggest -b:c tests/tchipmunk.nim
Hint: used config file '/home/daknus/.choosenim/toolchains/nim-1.4.0/config/nim.cfg' [Conf]
Hint: used config file '/home/daknus/.choosenim/toolchains/nim-1.4.0/config/config.nims' [Conf]
Hint: used config file '/home/daknus/.config/nim/nim.cfg' [Conf]
Hint: used config file '/home/daknus/.config/nim/config.nims' [Conf]
Hint: used config file '/home/daknus/Coding/Nim/rapid/tests/config.nims' [Conf]
usage: sug|con|def|use|dus|chk|mod|highlight|outline|known|project file.nim[;dirtyfile.nim]:line:col
type 'quit' to quit
type 'debug' to toggle debug mode on/off
type 'terse' to toggle terse mode on/off
> 

And also doesn't crash on Nim 1.2.6.

My hunch is that the compiler itself initializes the backend to C by default, but not nimsuggest, hence the assertion is hit because the default backend is backendInvalid.

@timotheecour
Copy link
Member

@liquid600pgm can you try right before this commit nim-lang/Nim#15549 as mentioned here:
nim-lang/Nim#15602 (comment)

@liquidev
Copy link
Author

As per @Clyybber's suggestion on Discord, I cleared the nimcache and everything works correctly so far. I'll reopen if this ever turns up again.

@timotheecour
Copy link
Member

having to clear the cache might be an acceptable-ish solution if using 2 different versions of nim, but not if using same version of nim and running some commands; is there a repro?

@liquidev
Copy link
Author

I was able to reproduce this using the following steps:

# before running anything we're on 1.4.0, in rapid's root folder
choosenim 1.2.6
nim c tests/tchipmunk
choosenim 1.4.0
nimsuggest tests/tchipmunk.nim

@timotheecour
Copy link
Member

thanks for the repro, I still think we should fix this

@liquidev
Copy link
Author

liquidev commented Oct 24, 2020

Seems to still be present, and quite annoying :/ reopening.

It can just crash in the middle of editing the file (using nim.nvim) which then forces me to stop writing code, switch to my terminal, rm -rf ~/.cache/nim, and restart nimsuggest via a custom command. And it makes compile times slower because the cache is now gone.

@liquidev liquidev reopened this Oct 24, 2020
@timotheecour
Copy link
Member

can you try #117 (comment) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants