adstraw commented on code in PR #13109:
URL: https://github.com/apache/tvm/pull/13109#discussion_r998449726


##########
src/runtime/hexagon/hexagon_buffer_manager.h:
##########
@@ -40,14 +40,19 @@ class HexagonBufferManager {
    * \param ptr Address of the HexagonBuffer as returned by 
`AllocateHexagonBuffer`.
    */
   void FreeHexagonBuffer(void* ptr) {
+    std::lock_guard<std::mutex> lock(mutex_);
+    // Check the list of buffers that were still allocated at the time of 
release.  If this buffer
+    // is in that list, this is a no-op as it is being freed as part of 
another object teardown.
+    auto it_released = std::find(released_buffers_.begin(), 
released_buffers_.end(), ptr);
+    if (it_released != released_buffers_.end()) {
+      released_buffers_.erase(it_released);
+      return;
+    }

Review Comment:
   Good point.  I added a change to `AllocateHexagonBuffer` to remove `ptr` 
from the list of `released_buffers_` so that it should only be in one data 
structure at a time.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to