Skip to content

Commit c684c56

Browse files
authored
Merge pull request #41891 from mikeash/fix-async-let-stackallocator
[Concurrency] Have StackAllocator gracefully fail when passed a small firstSlabBuffer.
2 parents 36b41d4 + adec767 commit c684c56

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

stdlib/public/runtime/StackAllocator.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,10 @@ class StackAllocator {
283283
numAllocatedSlabs(0) {}
284284

285285
/// Construct a StackAllocator with a pre-allocated first slab.
286-
StackAllocator(void *firstSlabBuffer, size_t bufferCapacity) {
286+
StackAllocator(void *firstSlabBuffer, size_t bufferCapacity) : StackAllocator() {
287+
// If the pre-allocated buffer can't hold a slab header, ignore it.
288+
if (bufferCapacity <= Slab::headerSize())
289+
return;
287290
char *start = (char *)llvm::alignAddr(firstSlabBuffer,
288291
llvm::Align(alignment));
289292
char *end = (char *)firstSlabBuffer + bufferCapacity;

0 commit comments

Comments
 (0)