Skip to content

fix(forward): fix sizeof bug in module config free#544

Merged
3Hren merged 1 commit intomainfrom
fix/acl-wrong-free
Mar 18, 2026
Merged

fix(forward): fix sizeof bug in module config free#544
3Hren merged 1 commit intomainfrom
fix/acl-wrong-free

Conversation

@3Hren
Copy link
Member

@3Hren 3Hren commented Mar 17, 2026

The forward_module_config_free used sizeof(struct forward_target *), which is 8 bytes instead of sizeof(struct forward_target) - 24 bytes when freeing the targets array.
This returned memory to the wrong block allocator pool, causing a silent memory leak on every config update.

Add cp_module_fini as a symmetric destructor for cp_module_init to properly release counter_registry and devices.

Add a forward module memory leak test that verifies block allocator free size is unchanged after a module create/free cycle.

@3Hren 3Hren force-pushed the fix/acl-wrong-free branch from ba572ce to 1c813ad Compare March 17, 2026 16:44
The "forward_module_config_free" used "sizeof(struct forward_target *)",
which is 8 bytes instead of "sizeof(struct forward_target)" - 24 bytes
when freeing the targets array.
This returned memory to the wrong block allocator pool, causing a silent
memory leak on every config update.

Add "cp_module_fini" as a symmetric destructor for "cp_module_init" to
properly release "counter_registry" and devices.

Add a forward module memory leak test that verifies block allocator free
size is unchanged after a module create/free cycle.
@3Hren 3Hren force-pushed the fix/acl-wrong-free branch from 35d9c0b to 9845b3e Compare March 17, 2026 16:51
@3Hren 3Hren changed the title WIP fix(forward): fix sizeof bug in module config free Mar 17, 2026
@3Hren 3Hren marked this pull request as ready for review March 17, 2026 16:53
@3Hren 3Hren merged commit 58a3570 into main Mar 18, 2026
10 checks passed
@3Hren 3Hren deleted the fix/acl-wrong-free branch March 18, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants