-
-
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
Regression in Nim 2.x handling of destructors/copies/moves for discarded variables #24586
Labels
Comments
Actually looks like 1.6 missed some destroys of Bar/Baz in On 1.6 without calling Output from Test1 on 1.6 without calling
Output on 1.6 with calling
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
A modified version of #24579 (comment) results in a double-free with ARC in
test1
. The second test using variables appears to be fine.It's not clear if
=destroy(x.fref)
shouldn't be called in=destroy*(x: var Baz)
in Nim 2.x but it does work with 1.6.20. This occurs on both Mac/arm64 and Linux/arm64.My take it that it looks like the discarded variables have lots of extra copies and destructions occuring. Also of note is that adding
proc =copy(x: var Bar) {.error.}
doesn't error. Similarly=wasMoved
doesn't appear to be called either.Run with:
nim c -d:debug -d:useMalloc --mm:arc -d:traceArc -d:nimArcDebug -r "destroytest.nim"
Nim Version
Nim Compiler Version 2.0.14 [Linux: arm64]
Compiled at 2024-12-23
Copyright (c) 2006-2023 by Andreas Rumpf
git hash: bf4de6a
active boot switches: -d:release -d:danger
Current Output
Expected Output
Known Workarounds
No response
Additional Information
Spawns from #24579
The text was updated successfully, but these errors were encountered: