Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

erasure-code: use new/delete to alloc/free coefficients array #56586

Merged
merged 1 commit into from May 3, 2024

Conversation

tchaikov
Copy link
Contributor

@tchaikov tchaikov commented Mar 29, 2024

before this change, we allocate coefficients table with malloc() in ErasureCodeIsaDefault::prepare(), but free them using delete. this is identified by LeakSanitizer, and it reports

==3135332==ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) on 0x60700002a870
    #0 0x5627c6ef721d in operator delete(void*) (/home/jenkins-build/build/workspace/ceph-pull-requests/build/bin/unittest_erasure_code_plugin_isa+0x1ca21d) (BuildId: 7922906370e5183d67f55211a868c0b0e22b4a2c)
    #1 0x7fbbe38e858f in ErasureCodeIsaTableCache::~ErasureCodeIsaTableCache() /home/jenkins-build/build/workspace/ceph-pull-requests/src/erasure-code/isa/ErasureCodeIsaTableCache.cc:65:13
    #2 0x7fbbe390be40 in ErasureCodePluginIsa::~ErasureCodePluginIsa() /home/jenkins-build/build/workspace/ceph-pull-requests/src/erasure-code/isa/ErasureCodePluginIsa.h:24:7
    #3 0x7fbbe390be68 in ErasureCodePluginIsa::~ErasureCodePluginIsa() /home/jenkins-build/build/workspace/ceph-pull-requests/src/erasure-code/isa/ErasureCodePluginIsa.h:24:7
    #4 0x5627c7063b52 in ceph::ErasureCodePluginRegistry::~ErasureCodePluginRegistry() /home/jenkins-build/build/workspace/ceph-pull-requests/src/erasure-code/ErasureCodePlugin.cc:49:5
    #5 0x7fbbeccb6494 in __run_exit_handlers stdlib/./stdlib/exit.c:113:8
    #6 0x7fbbeccb660f in exit stdlib/./stdlib/exit.c:143:3
    #7 0x7fbbecc9ad96 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:74:3
    #8 0x7fbbecc9ae3f in __libc_start_main csu/../csu/libc-start.c:392:3
    #9 0x5627c6e38da4 in _start (/home/jenkins-build/build/workspace/ceph-pull-requests/build/bin/unittest_erasure_code_plugin_isa+0x10bda4) (BuildId: 7922906370e5183d67f55211a868c0b0e22b4a2c)

so, in this change, we use new [] and delete [] to allocate and free them, to be more consistent, and to silence this warning.

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows
  • jenkins test rook e2e

@tchaikov tchaikov requested a review from a team as a code owner March 29, 2024 23:50
@github-actions github-actions bot added the core label Mar 29, 2024
Copy link
Contributor

@athanatos athanatos left a comment

Choose a reason for hiding this comment

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

Yup

@tchaikov
Copy link
Contributor Author

pushed to https://shaman.ceph.com/builds/ceph/wip-pr-56586-kefu/22e9098308a4561faf7db77e1adaa49d25d780fa/, to build test it. but would be ideal if we can run it through teuthology tests.

before this change, we allocate coefficients table with
`malloc()` in `ErasureCodeIsaDefault::prepare()`, but free them using
`delete`. this is identified by LeakSanitizer, and it reports

```
==3135332==ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) on 0x60700002a870
    #0 0x5627c6ef721d in operator delete(void*) (/home/jenkins-build/build/workspace/ceph-pull-requests/build/bin/unittest_erasure_code_plugin_isa+0x1ca21d) (BuildId: 7922906370e5183d67f55211a868c0b0e22b4a2c)
    #1 0x7fbbe38e858f in ErasureCodeIsaTableCache::~ErasureCodeIsaTableCache() /home/jenkins-build/build/workspace/ceph-pull-requests/src/erasure-code/isa/ErasureCodeIsaTableCache.cc:65:13
    #2 0x7fbbe390be40 in ErasureCodePluginIsa::~ErasureCodePluginIsa() /home/jenkins-build/build/workspace/ceph-pull-requests/src/erasure-code/isa/ErasureCodePluginIsa.h:24:7
    #3 0x7fbbe390be68 in ErasureCodePluginIsa::~ErasureCodePluginIsa() /home/jenkins-build/build/workspace/ceph-pull-requests/src/erasure-code/isa/ErasureCodePluginIsa.h:24:7
    #4 0x5627c7063b52 in ceph::ErasureCodePluginRegistry::~ErasureCodePluginRegistry() /home/jenkins-build/build/workspace/ceph-pull-requests/src/erasure-code/ErasureCodePlugin.cc:49:5
    #5 0x7fbbeccb6494 in __run_exit_handlers stdlib/./stdlib/exit.c:113:8
    #6 0x7fbbeccb660f in exit stdlib/./stdlib/exit.c:143:3
    #7 0x7fbbecc9ad96 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:74:3
    #8 0x7fbbecc9ae3f in __libc_start_main csu/../csu/libc-start.c:392:3
    #9 0x5627c6e38da4 in _start (/home/jenkins-build/build/workspace/ceph-pull-requests/build/bin/unittest_erasure_code_plugin_isa+0x10bda4) (BuildId: 7922906370e5183d67f55211a868c0b0e22b4a2c)
```

so, in this change, we use `new []` and `delete []` to allocate and free
them, to be more consistent, and to silence this warning.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
@tchaikov
Copy link
Contributor Author

changelog

  • use delete[] which was delete, since we use new [] to allocate the array, we should use delete [] at all places freeing it.

@tchaikov
Copy link
Contributor Author

being tested at #56537

@yuriw
Copy link
Contributor

yuriw commented Apr 17, 2024

This PR is under test in https://tracker.ceph.com/issues/65560.

@Svelar Svelar dismissed their stale review April 22, 2024 08:02

Nothing is related with this changes. Would file another PR.

@tchaikov
Copy link
Contributor Author

Nothing is related with this changes. Would file another PR.

@Svelar thanks!

@amathuria
Copy link
Contributor

@yuriw yuriw merged commit c2fb3ab into ceph:main May 3, 2024
10 of 11 checks passed
@tchaikov tchaikov deleted the wip-erasure-code-new branch May 3, 2024 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants