PaddlePaddle / PaddlePaddle/FastDeploy

CAPI 重OneDimDetectionResult 调用释放内存释方法后崩溃

Open
#2,437 3 comments 0 reactions 1 assignee View on GitHub

@jiangjiajun is already working on this.

Since Apr 19, 2024.

Dominant language
Python
Stars
3.7k
Forks
756
Avg merge
19h 28m
Merged PRs (30d)
4

Description

void FD_C_DestroyDetectionResult(
    __fd_take FD_C_DetectionResult* fd_c_detection_result) {
  if (fd_c_detection_result == nullptr) return;
  // delete boxes
  for (size_t i = 0; i < fd_c_detection_result->boxes.size; i++) {
    delete[] fd_c_detection_result->boxes.data[i].data;
  }
  delete[] fd_c_detection_result->boxes.data;
  // delete scores
  delete[] fd_c_detection_result->scores.data;
  // delete label_ids
  delete[] fd_c_detection_result->label_ids.data;
  // delete masks
  for (size_t i = 0; i < fd_c_detection_result->masks.size; i++) {
    delete[] fd_c_detection_result->masks.data[i].data.data;
    delete[] fd_c_detection_result->masks.data[i].shape.data;
  }
  delete fd_c_detection_result;
}

我添加一个释放方法

void FD_C_DestroyOneDimDetectionResult(
    __fd_take FD_C_OneDimDetectionResult* fd_c_one_dim_detection_result) {
  for (int i = 0; i < fd_c_one_dim_detection_result->size; i++) {
    FD_C_DestroyDetectionResult(fd_c_one_dim_detection_result->data + i);
  }
  delete[] fd_c_one_dim_detection_result->data;
  delete fd_c_one_dim_detection_result;
}
在调用FD_C_DestroyOneDimDetectionResult的时候,走到FD_C_DestroyDetectionResult的最后一行 delete fd_c_detection_result;出问题了,具体问题:
  • 如果OneDimDetectionResult是里面有俩结果,在for循环中调用释放方法的时候i为0的时候没问题,i为1的时候报错了。直接崩溃崩溃在delete fd_c_detection_result;

有大伙知道啥情况吗?有没有人测过?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.