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

fixes #24504; fixes ensureMove for refs #24505

Merged
merged 5 commits into from
Dec 5, 2024
Merged

fixes #24504; fixes ensureMove for refs #24505

merged 5 commits into from
Dec 5, 2024

Conversation

ringabout
Copy link
Member

@ringabout ringabout commented Dec 4, 2024

fixes #24504

hasDestructor(n[1].typ):
result = p(n[1], c, s, normal)
else:
result = p(n[1], c, s, sinkArg)
dec c.inEnsureMove
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the real problem here is your special case and the return. Instead the usual logic should be performed where the diagnosis intercepts c.inEnsureMove.

Copy link
Member Author

@ringabout ringabout Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most logic of normal calls are not needed for ensureMove. The bug is that when a value is moved to a location (sinkArg), the location should own the value and ensure its destruction. (Another way is to translate ensureMove(x) into move(x) instead of =sink(x))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So where did you get this logic from?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead the usual logic should be performed where the diagnosis intercepts c.inEnsureMove.

Okay, I removed the special treatment. Though I need to pass the paramenter of ensureMove with sinkArg?

@ringabout ringabout marked this pull request as ready for review December 4, 2024 14:50
@Araq
Copy link
Member

Araq commented Dec 5, 2024

@narimiran this needs to be backported to every relevant version.

@Araq Araq merged commit d0288d3 into devel Dec 5, 2024
21 checks passed
@Araq Araq deleted the pr_24504 branch December 5, 2024 20:37
Copy link
Contributor

github-actions bot commented Dec 5, 2024

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from d0288d3

Hint: mm: orc; opt: speed; options: -d:release
177983 lines; 9.133s; 653.629MiB peakmem

narimiran pushed a commit that referenced this pull request Dec 8, 2024
narimiran pushed a commit that referenced this pull request Jan 14, 2025
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 this pull request may close these issues.

ensureMove usage leading to memory leak for JsonNode !
2 participants