Skip to content

Tracking provider cannot change behavior of upstream provider #146

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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/provider/provider_tracking.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ static umf_result_t trackingAlloc(void *hProvider, size_t size,
return ret;
}

ret = umfMemoryTrackerAdd(p->hTracker, p->pool, *ptr, size);
if (ret != UMF_RESULT_SUCCESS && p->hUpstream) {
if (umfMemoryProviderFree(p->hUpstream, *ptr, size)) {
// TODO: LOG
}
umf_result_t ret2 = umfMemoryTrackerAdd(p->hTracker, p->pool, *ptr, size);
if (ret2 != UMF_RESULT_SUCCESS) {
// DO NOT call umfMemoryProviderFree() here, because the tracking provider
// cannot change behaviour of the upstream provider.
// TODO: LOG
}

return ret;
Expand All @@ -131,7 +131,9 @@ static umf_result_t trackingFree(void *hProvider, void *ptr, size_t size) {
if (ptr) {
ret = umfMemoryTrackerRemove(p->hTracker, ptr, size);
if (ret != UMF_RESULT_SUCCESS) {
return ret;
// DO NOT return an error here, because the tracking provider
// cannot change behaviour of the upstream provider.
// TODO: LOG
}
}

Expand Down