Skip to content

Revert "[Reflection] Add API for inspecting async task allocation slabs." #40236

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
merged 1 commit into from
Nov 18, 2021

Conversation

compnerd
Copy link
Member

Reverts #40071

This causes use of uninitialized memory on Windows. https://ci-external.swift.org/job/oss-swift-windows-x86_64-vs2019/7174/

@compnerd
Copy link
Member Author

@swift-ci please test

@compnerd
Copy link
Member Author

Local testing (in conjunction with @mikeash) indicates that removal of the metadata field does "repair" the failure.

diff --git a/stdlib/public/runtime/StackAllocator.h b/stdlib/public/runtime/StackAllocator.h
index bbcc2a01e9b..1229ad99725 100644
--- a/stdlib/public/runtime/StackAllocator.h
+++ b/stdlib/public/runtime/StackAllocator.h
@@ -89,10 +89,6 @@ private:
   /// This struct is actually just the slab header. The slab buffer is tail
   /// allocated after Slab.
   struct Slab {
-    /// A fake metadata pointer that analysis tools can use to identify slab
-    /// allocations.
-    const void *metadata;
-
     /// A single linked list of all allocated slabs.
     Slab *next = nullptr;

@@ -103,7 +99,7 @@ private:
     // Here starts the tail allocated memory buffer of the slab.

     Slab(size_t newCapacity)
-        : metadata(SlabMetadataPtr), capacity(newCapacity) {
+        : capacity(newCapacity) {
       assert((size_t)capacity == newCapacity && "capacity overflow");
     }

It is likely an alignment issue lurking somewhere. The uninitialized region of the structure was partially overlapping, which aligns (ha ha) well here.

@compnerd compnerd merged commit d104e12 into main Nov 18, 2021
@compnerd compnerd deleted the revert-40071-remote-mirror-async-slab-inspection branch November 18, 2021 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant