Skip to content

Release ref count on timing information when freeing draw state. #1011

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

Closed

Conversation

litghost
Copy link
Collaborator

No description provided.

@probot-autolabeler probot-autolabeler bot added lang-cpp C/C++ code VPR VPR FPGA Placement & Routing Tool labels Oct 18, 2019
@kmurray
Copy link
Contributor

kmurray commented Oct 25, 2019

@litghost Could you add a comment describing why this is needed?

I think its because the draw state will otherwise hold onto the timing analyzer forever (shared_ptr semantics). But this shouldn't cause any real memory leaks in the standard tool flow, since whenever the graphics were passed a new timing analyzer its assigned to draw_sate->setup_timing_info, which would decrement the ref count on the old (previously held analyzer, and increment the new ref count). Correct?

@litghost
Copy link
Collaborator Author

@litghost Could you add a comment describing why this is needed?

Sure

I think its because the draw state will otherwise hold onto the timing analyzer forever (shared_ptr semantics). But this shouldn't cause any real memory leaks in the standard tool flow, since whenever the graphics were passed a new timing analyzer its assigned to draw_sate->setup_timing_info, which would decrement the ref count on the old (previously held analyzer, and increment the new ref count). Correct?

Your analysis doesn't account for what happens VPR is terminating. draw_sate->setup_timing_info is never cleared, then it's refcount is always 1 at termination. As a result it looks like a leak of the setup_timing_info at termination.

@litghost
Copy link
Collaborator Author

It is interesting though, the shared_ptr should be cleared after main exits, but asan/leak sanitizer did find a leak related to this shared_ptr. Adding this reset resolved the leak sanitizer report, but I wonder if it might be an error in leak sanitizer?

@kmurray
Copy link
Contributor

kmurray commented Oct 25, 2019

It is interesting though, the shared_ptr should be cleared after main exits, but asan/leak sanitizer did find a leak related to this shared_ptr.

Yes, I'd expect it to be cleaned-up then as well.

Just speculating, but I've seen cases in the past in VPR, where constructors/destructors weren't being called correctly since the containing struct was allocated with malloc instead of new (motivating #506). Perhaps that could be the case with draw_state?

@litghost
Copy link
Collaborator Author

Just speculating

Good idea, but nope: https://github.com/verilog-to-routing/vtr-verilog-to-routing/blob/master/vpr/src/draw/draw_global.cpp#L22 . I'll need to dig into this later.

@litghost litghost closed this Apr 16, 2020
@litghost litghost deleted the dont_leak_timing branch April 16, 2020 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang-cpp C/C++ code VPR VPR FPGA Placement & Routing Tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants