Repository navigation
Conversation
Limit hpa_sec_nshards and experimental_pac_sec_nshards to 255 to prevent uint8_t overflow and multiplication overflow during initialization.
Contributor
Author
|
I've pushed a fix for the AppVeyor test failure (: Should own 0 locks of rank >= 14: extent_grow(17)). The error paths in extent_grow_retained and extent_recycle_split were calling extent_dalloc_wrapper while holding pac->grow_mtx (rank 17), which caused a lock rank violation since extent_dalloc_wrapper requires no core locks to be held. I've updated the code to drop the lock before deallocating. |
Contributor
Author
|
@guangli-dai please review |
Contributor
|
Some CIs are failing including windows, mac, and more. Can you fix? Also, please rebase to dev and this commit can be removed. |
| edata_cache_put(tsdn, pac->edata_cache, edata); | ||
| } | ||
|
|
||
| return err; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2815
Description
This PR addresses a memory leak that occurs when custom extent hooks are used, specifically when the custom
splithook returns an error (failure to split).Previously, if
extent_recycle_splitorextent_grow_retainedrequested a split via thesplithook and it failed, the code would handle the failure by callingextents_abandon_vmon the un-splittable region. Whileextents_abandon_vmproperly cleans up internal extent metadata, it leaks the underlying virtual memory mapping. The user's customdallochook was never invoked to clean up the original allocation.This PR modifies the failure paths in
extent_recycle_splitandextent_grow_retainedto explicitly callextent_dalloc_wrapperinstead ofextents_abandon_vm. This ensures thatjemallocappropriately delegates the un-splittable region back to the custom deallocation hook (dalloc), completely preventing the virtual memory leak.Changes Made
src/extent.c: extent_recycle_split: Replaced calls toextents_abandon_vmwithextent_dalloc_wrapperfor theto_salvageandto_leaksegments when a split operation fails.src/extent.c: extent_grow_retained: Replaced the call toextents_abandon_vmwithextent_dalloc_wrapperon the split failure path.src/extent.c: extent_grow_retained: Addedextent_gdump_add(tsdn, to_salvage)andextent_gdump_add(tsdn, to_leak)right before their respective deallocations to ensure heap profiling metadata remains balanced during the failure path cleanup.Verification
alloc,split, anddallochooks were registered.splithook to always returntrue(failure).custom_dallocis successfully invoked to clean up the allocation after the split failure.