PaddlePaddle / Paddle

PArallel Distributed Deep LEarning: Machine Learning Framework from Industrial Practice (『飞桨』核心框架,深度学习&机器学习高性能单机、分布式训练和跨平台部署)
http://www.paddlepaddle.org/
Apache License 2.0
21.66k stars 5.44k forks source link

【Hackathon 6th Fundable Projects 2 No.19】cppcoreguidelines-no-malloc-final #63752

Open walkalone20 opened 3 weeks ago

walkalone20 commented 3 weeks ago

PR Category

Others

PR Types

Bug fixes

Description

修复了 C 风格的 malloc、free 的共计 23 个错误。该问题共 27 处,还有 4 处涉及到函数参数是指针,在函数内或跨函数释放的情况:

/paddle/Paddle/paddle/phi/api/profiler/device_tracer.cc:179:46: error: do not manage memory manually; consider a container or a smart pointer [cppcoreguidelines-no-malloc,-warnings-as-errors]
  uint8_t *buf = reinterpret_cast<uint8_t *>(malloc(kBufSize + kAlignSize));
                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/paddle/Paddle/paddle/fluid/framework/new_executor/workqueue/workqueue_utils.cc:49:3: error: do not manage memory manually; use RAII [cppcoreguidelines-no-malloc,-warnings-as-errors]
  free(mem_ptr);
  ^~~~~~~~~~~~~
/paddle/Paddle/paddle/pir/src/core/utils.cc:51:3: error: do not manage memory manually; use RAII [cppcoreguidelines-no-malloc,-warnings-as-errors]
  free(mem_ptr);
  ^~~~~~~~~~~~~
/paddle/Paddle/paddle/phi/api/profiler/device_tracer.cc:309:3: error: do not manage memory manually; use RAII [cppcoreguidelines-no-malloc,-warnings-as-errors]
  free(buffer);
  ^~~~~~~~~~~~

相关链接: https://github.com/PaddlePaddle/Paddle/issues/54073

CLAassistant commented 3 weeks ago

CLA assistant check
All committers have signed the CLA.

CLAassistant commented 3 weeks ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

paddle-bot[bot] commented 3 weeks ago

你的PR提交成功,感谢你对开源项目的贡献! 请关注后续CI自动化测试结果,详情请参考Paddle-CI手册。 Your PR has been submitted. Thanks for your contribution! Please wait for the result of CI firstly. See Paddle CI Manual for details.

paddle-ci-bot[bot] commented 2 weeks ago

Sorry to inform you that 9844a3b's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

paddle-ci-bot[bot] commented 1 week ago

Sorry to inform you that ae6e00e's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.