Skip to content

Conversation

@ldorau
Copy link
Contributor

@ldorau ldorau commented Mar 5, 2025

Description

Fix disjoint_pool_free() and proxy_free() - error out on pool mismatch, when we try to free the pointer
belonging to a different pool.

Checklist

  • Code compiles without errors locally
  • All tests pass locally
  • CI workflows execute properly

@ldorau ldorau requested a review from a team as a code owner March 5, 2025 10:42
return ret;
}

if (pool != umfPoolGetPoolPriv(allocInfo.pool)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this check? It breaks encapsulation because now pool implementation calls umfPoolGetPoolPriv.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check prevents from freeing a pointer from a different pool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vinser52 It is needed by #1143
See #1143 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure we should expose UMF internals to the pool implementation.

Furthermore, this solution works only for UMF's pools. If someone implements their pool what he/she should do in that case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR was replaced with #1161 - please review this new PR instead.

@vinser52
Copy link
Contributor

vinser52 commented Mar 5, 2025

The name of this PR is misleading because it does not fix anything, it just introduces an additional check. But do we really need this check?

@ldorau
Copy link
Contributor Author

ldorau commented Mar 5, 2025

The name of this PR is misleading because it does not fix anything, it just introduces an additional check. But do we really need this check?

proxy_pool_free() can free a pointer from a different pool than it was called with now. I think it is a bug, so this is a fix for this bug.

Fix disjoint_pool_free() and proxy_free() - error out
on pool mismatch, when we try to free the pointer
belonging to a different pool.

Signed-off-by: Lukasz Dorau <[email protected]>
@ldorau ldorau force-pushed the Fix_disjoint_pool_free_and_proxy_free branch from 5300876 to 32175d9 Compare March 5, 2025 14:24
@ldorau ldorau requested review from bratpiorka and vinser52 March 5, 2025 14:31
@vinser52
Copy link
Contributor

vinser52 commented Mar 5, 2025

The name of this PR is misleading because it does not fix anything, it just introduces an additional check. But do we really need this check?

proxy_pool_free() can free a pointer from a different pool than it was called with now. I think it is a bug, so this is a fix for this bug.

it is the ill-formed client.

@igchor
Copy link
Contributor

igchor commented Mar 5, 2025

I'm not sure if adding this check in the pool is a good idea. As I understand, all other pools will NOT return an error if we try to free memory from a different pool (which is inconsistent). And even if we added this check to proxy_pool, jemalloc_pool, what about custom user pools?

@ldorau
Copy link
Contributor Author

ldorau commented Mar 6, 2025

I'm not sure if adding this check in the pool is a good idea. As I understand, all other pools will NOT return an error if we try to free memory from a different pool (which is inconsistent). And even if we added this check to proxy_pool, jemalloc_pool, what about custom user pools?

This PR was replaced with #1161 - please review this new PR instead.

@ldorau ldorau closed this Mar 6, 2025
@ldorau ldorau deleted the Fix_disjoint_pool_free_and_proxy_free branch March 13, 2025 14:10
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.

4 participants