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

Commits on Mar 30, 2024

  1. erasure-code: use new/delete to alloc/free coefficients array

    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 committed Mar 30, 2024
    Configuration menu
    Copy the full SHA
    6a88e09 View commit details
    Browse the repository at this point in the history