apollo icon indicating copy to clipboard operation
apollo copied to clipboard

memory leak in modules/planning/math/piecewise_jerk/piecewise_jerk_problem.cc

Open acmol opened this issue 2 years ago • 2 comments

Describe the bug

OSQPData* data = reinterpret_cast<OSQPData*>(c_malloc(sizeof(OSQPData)));

This variable data was never freed. The csc_matrixies was never freed neither.

void PiecewiseJerkProblem::FreeData(OSQPData* data) {
  delete[] data->q;
  delete[] data->l;
  delete[] data->u;

  delete[] data->P->i;
  delete[] data->P->p;
  delete[] data->P->x;
  c_free(data->P);

  delete[] data->A->i;
  delete[] data->A->p;
  delete[] data->A->x;
  c_free(data->A);

  c_free(data);
}

may fix this bug.

To Reproduce

You can use address sanitizer to examine the leaking.

I've started a pull request to fix a fd leak in https://github.com/ApolloAuto/apollo/pull/14309 , but no one cares my fixing. So I lost my patient on testing the fixing uppon. And just report the bug here - -, to fix or not, it's your decision.

acmol avatar Apr 20 '22 02:04 acmol

maybe you have helped me to solve the coredump problem,according to your tips.

zhaofuxie avatar Apr 20 '22 06:04 zhaofuxie

Thanks for your pr, maybe you have solved the bug, could you add a new pr to fix it.We will merge into master

qwetqwe avatar Jul 12 '22 03:07 qwetqwe