don't return raw span when sampling and stacktrace oomed

This is nearly impossible in practice, but still. Somehow we missed
this logic that DoSampledAllocation always returns actual object, but
in that condition where stacktrace_allocator failed to get us
StackTrace object we ended up returning span instead of it's object.
This commit is contained in:
Aliaksey Kandratsenka 2023-07-24 18:57:52 -04:00
parent 59464404d1
commit d2c89ba534

View File

@ -1177,14 +1177,12 @@ static void* DoSampledAllocation(size_t size) {
// Allocate stack trace
StackTrace *stack = Static::stacktrace_allocator()->New();
if (PREDICT_FALSE(stack == NULL)) {
// Sampling failed because of lack of memory
return span;
}
if (PREDICT_TRUE(stack != nullptr)) {
*stack = tmp;
span->sample = 1;
span->objects = stack;
tcmalloc::DLL_Prepend(Static::sampled_objects(), span);
}
return SpanToMallocResult(span);
#else