-
Notifications
You must be signed in to change notification settings - Fork 42
Do not free a pointer from another pool #1161
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
Do not free a pointer from another pool #1161
Conversation
Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
|
|
||
| umf_result_t umfPoolFree(umf_memory_pool_handle_t hPool, void *ptr) { | ||
| UMF_CHECK((hPool != NULL), UMF_RESULT_ERROR_INVALID_ARGUMENT); | ||
| umf_memory_pool_handle_t poolTracker = umfMemoryTrackerGetPool(ptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with this call, we would search the tracker 2 times during the free?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK in case of Proxy Pool and Disjoint Pool - yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this could significantly hurt the performance. Could you run the benchmarks and ask @lplewa for interpretation of results?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this problem specific to the disjoint and proxy pools? Does the issue exist with the scalable or with the jemalloc pools?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is theoretically possible for every pool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @bratpiorka mentioned it might impact performance.
so it is obvious that if an incorrect pool handle is passed by the client it is an ill-formed client's code. The question is do we want to catch such issues (and probably pay for the performance impact) or we should just say it is "undefined behavior" if an incorrect pool handle is passed as a parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I vote for UB in such case.
|
Passing an incorrect pool handle to |
perhaps should we update the docs? |
Description
Passing an incorrect pool handle to umfPoolFree() is an Undefined Behavior.
Checklist