aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Goldblatt <davidgoldblatt@fb.com>2018-04-17 13:16:42 -0700
committerDavid Goldblatt <davidtgoldblatt@gmail.com>2018-04-18 08:19:41 -0700
commitc95284df1ab77f233562d9bc826523cfaaf7f41e (patch)
tree7ec16f1bd196a90b59517e2aec1b781f3e49d5a2 /src
parenta62e42baebe09dc84aaff731faa6ff87fde6bc4e (diff)
downloadplatform_external_jemalloc_new-c95284df1ab77f233562d9bc826523cfaaf7f41e.tar.gz
platform_external_jemalloc_new-c95284df1ab77f233562d9bc826523cfaaf7f41e.tar.bz2
platform_external_jemalloc_new-c95284df1ab77f233562d9bc826523cfaaf7f41e.zip
Avoid a resource leak down extent split failure paths.
Previously, we would leak the extent and memory associated with a salvageable portion of an extent that we were trying to split in three, in the case where the first split attempt succeeded and the second failed.
Diffstat (limited to 'src')
-rw-r--r--src/extent.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/extent.c b/src/extent.c
index 49b6d4b8..09d6d771 100644
--- a/src/extent.c
+++ b/src/extent.c
@@ -1319,21 +1319,19 @@ extent_grow_retained(tsdn_t *tsdn, arena_t *arena,
* cant_alloc case should not occur.
*/
assert(result == extent_split_interior_error);
+ if (to_salvage != NULL) {
+ if (config_prof) {
+ extent_gdump_add(tsdn, to_salvage);
+ }
+ extent_record(tsdn, arena, r_extent_hooks,
+ &arena->extents_retained, to_salvage, true);
+ }
if (to_leak != NULL) {
extent_deregister_no_gdump_sub(tsdn, to_leak);
extents_leak(tsdn, arena, r_extent_hooks,
&arena->extents_retained, to_leak, true);
- goto label_err;
}
- /*
- * Note: we don't handle the non-NULL to_salvage case at all.
- * This maintains the behavior that was present when the
- * refactor pulling extent_split_interior into a helper function
- * was added. I think this is actually a bug (we leak both the
- * memory and the extent_t in that case), but since this code is
- * getting deleted very shortly (in a subsequent commit),
- * ensuring correctness down this path isn't worth the effort.
- */
+ goto label_err;
}
if (*commit && !extent_committed_get(extent)) {