Skip to content

Move ref vs retain when stealing pointer for structured args. - #9962

Merged
stellaraccident merged 2 commits into
mainfrom
fix_dangling_struct
Jul 30, 2022
Merged

stellaraccident merged 2 commits into
mainfrom
fix_dangling_struct

Conversation

@stellaraccident

Copy link
Copy Markdown
Collaborator

This was a bit tricky to track down. It only affects structured argument
packing/unpacking. We were leaking a reference to the sub-list, which,
given that it usually contains buffers, was causing a leak of any
contained device backed memory buffers. Then much later, with asserts
enabled, the vulkan driver would notice that not all allocated memory
was freed and assert.

I am not completely sure on the cause of the non-determinism. Since the
problem manifests on shutdown, I'm (just guessing) that the normal
shutdown process may be bypassed sometimes? This does only affect a
subset of TF-specific invocation schemes, and until that was obvious, it
was difficult to see the pattern.

Fixes #9936

This was a bit tricky to track down. It only affects structured argument
packing/unpacking. We were leaking a reference to the sub-list, which,
given that it usually contains buffers, was causing a leak of any
contained device backed memory buffers. Then much later, with asserts
enabled, the vulkan driver would notice that not all allocated memory
was freed and assert.

I am not completely sure on the cause of the non-determinism. Since the
problem manifests on shutdown, I'm (just guessing) that the normal
shutdown process may be bypassed sometimes? This does only affect a
subset of TF-specific invocation schemes, and until that was obvious, it
was difficult to see the pattern.

Fixes #9936
@GMNGeoffrey

Copy link
Copy Markdown
Member

Thanks! Can you try patching in the changes from #9954 to confirm this fixes that issue? It's just a one-line change to the CI to enable these tests.

@stellaraccident

Copy link
Copy Markdown
Collaborator Author

Thanks! Can you try patching in the changes from #9954 to confirm this fixes that issue? It's just a one-line change to the CI to enable these tests.

Done, but given that I timed this to let me leave precisely at 5pm on Friday... if it doesn't actually work, I will cry.

@GMNGeoffrey GMNGeoffrey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! Can you try patching in the changes from #9954 to confirm this fixes that issue? It's just a one-line change to the CI to enable these tests.

Done, but given that I timed this to let me leave precisely at 5pm on Friday... if it doesn't actually work, I will cry.

It works! 🙂 Approving because this fixes the bug, but maybe @benvanik wants to review the substance of this

Comment thread runtime/bindings/python/invoke.cc Resolved
@stellaraccident
stellaraccident requested a review from benvanik July 30, 2022 00:26
@stellaraccident
stellaraccident merged commit f40838d into main Jul 30, 2022
@stellaraccident
stellaraccident deleted the fix_dangling_struct branch July 30, 2022 01:14
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.

TF integrations Python + Vulkan failures

3 participants