> nim c main.nim
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
On compilation, I get only this message.
How can I find the source of error (Illegal storage access) in my code?
Nim Compiler Version 1.6.6 [Windows: i386]
Compiled at 2022-05-05
Copyright (c) 2006-2021 by Andreas Rumpf
active boot switches: -d:release
Why are you running a 32-bit version of the compiler?
Does this happen for a very minimal program, e.g. echo "hello world"?
If not, try commenting out code in your program until you've narrowed down which line is causing the compiler to crash, and post that line here.
You can try using
import segfaults
In your main nim file. It might be able to give you a traceback.
import segfaults
added to his main.nim source text can catch a compiler issue? I am surprised, but your reply got two likes, so it may indeed be true.
>On compilation, I get only this message.
For debugging the compiler, I found this: https://github.com/nim-lang/Nim/wiki/Debugging-the-compiler
Yesterday I also had a compilation message with version 1.6.6 it could no longer compile even a small example.
I reloaded 1.6.4 everything worked perfectly. I deleted 1.6.6 then reloaded everything is back to normal. etc... ????
I had reported the issue, but deleted it thinking it was mine.
Actually, I misunderstood the docs. Importing the segfaults module allows you to catch a segfault like you would an exception.
So you could do:
import segfaults
proc main() =
try:
doSegfault()
except:
echo "segfault caught!"
echo getCurrentException().getStackTrace()
But it looks like this may not help OP. It could also be a compiler segfault, which would happen before any code on his end gets executed.
@bijinpanicker, can you share a minimum example that causes your issue?
Importing the segfaults module allows you to catch a segfault like you would an exception.
Though, I think I remember reading, that this is not intended and is just a side-effect, which is too often exploited. Additionally, segfaults is considered broken.
From my experience, you most of the time cannot catch segfaults, just because you imported that module.