Skip to content

erasure-code/jerasure: fix memory leak in Galois field operations#64226

Merged
tchaikov merged 1 commit intoceph:mainfrom
tchaikov:wip-ec-jerasure-fix-leak
Jul 11, 2025
Merged

erasure-code/jerasure: fix memory leak in Galois field operations#64226
tchaikov merged 1 commit intoceph:mainfrom
tchaikov:wip-ec-jerasure-fix-leak

Conversation

@tchaikov
Copy link
Contributor

@tchaikov tchaikov commented Jun 27, 2025

Fix a memory leak where Galois field acceleration functions created by
ErasureCodeJerasure::prepare() were never freed. ASan detected this as
a one-time leak when the plugin was unloaded.

Add jerasure_finish() destructor function in jerasure_init.cc to free
the allocated Galois field operations. Since jerasure_init.cc and
galois.c are built into the same object library, jerasure_finish() can
access and clean up the global static acceleration functions defined
in galois.c.

The destructor function is automatically called when the shared library
(plugin) is unloaded, ensuring proper cleanup without requiring explicit
calls from client code.

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

@tchaikov tchaikov requested a review from a team as a code owner June 27, 2025 14:03
@github-actions github-actions bot added the core label Jun 27, 2025
@tchaikov tchaikov mentioned this pull request Jun 27, 2025
14 tasks
@tchaikov tchaikov force-pushed the wip-ec-jerasure-fix-leak branch from 1671f86 to 22d67ab Compare June 28, 2025 13:38
@tchaikov
Copy link
Contributor Author

@ceph/core hello maintainers, could you please help review this change?

Copy link
Contributor

@ronen-fr ronen-fr left a comment

Choose a reason for hiding this comment

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

LGTM (which some nits, and a question)

@tchaikov tchaikov force-pushed the wip-ec-jerasure-fix-leak branch from 22d67ab to 4598023 Compare July 10, 2025 09:25
@tchaikov
Copy link
Contributor Author

changelog:

  • drop the trailing "z" in comment.

Fix a memory leak where Galois field acceleration functions created by
ErasureCodeJerasure::prepare() were never freed. ASan detected this as
a one-time leak when the plugin was unloaded.

Add jerasure_finish() destructor function in jerasure_init.cc to free
the allocated Galois field operations. Since jerasure_init.cc and
galois.c are built into the same object library, jerasure_finish() can
access and clean up the global static acceleration functions defined
in galois.c.

The destructor function is automatically called when the shared library
(plugin) is unloaded, ensuring proper cleanup without requiring explicit
calls from client code.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
@tchaikov tchaikov force-pushed the wip-ec-jerasure-fix-leak branch from 4598023 to 08d7363 Compare July 10, 2025 09:31
@tchaikov
Copy link
Contributor Author

jenkins test make check

@tchaikov
Copy link
Contributor Author

jenkins test make check arm64

@tchaikov tchaikov merged commit 5d9d311 into ceph:main Jul 11, 2025
13 checks passed
@tchaikov tchaikov deleted the wip-ec-jerasure-fix-leak branch July 11, 2025 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants