-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
hashSetSeq[^1].incl segfaults in VM #10981
Comments
Gives the correct output with debug compiler (koch temp) and no crashes. |
Can you re-check that? |
|
@nc-x Hm, can you show the output of |
@narimiran |
|
Similar bug happened in HashSet of Table. Example Additional Information |
Cannot reproduce on devel |
IDK how |
After a bit of debugging, I have found this problematic code: Line 4033 in 212ae2f
The last four instructions are:
The proc passes the return value in the register 0, which after this point has a dangling |
Minimal example: type Bar = ref object
baz: int
proc foo(b: var Bar, i: int): var int =
if i == 0:
return b.baz
else:
return foo(b, i - 1)
proc quux(n: int) =
if n > 0:
quux(n - 1)
proc qux(c: var int) =
for i in 0 ..< 10000: # force gc collection of old stack frames
quux(10)
echo c # use c after the loop only
static:
var b = Bar(baz: 2)
qux(foo(b, 100)) |
Some bugs with NimVM are fixed in nim-lang/Nim#10981. It maybe makes our macros stable, so I remove some echos in compile and Version bump.
Example
Current Output
Expected Output
Possible Solution
Workarounds:someSets[someSets.len - 1]
This just delays (nondeterministically) the segfault to later usage of VM.
Additional Information
The text was updated successfully, but these errors were encountered: