Skip to content

Rc/Arc for DST compute layout incorrectly #55747

Closed
@RalfJung

Description

@RalfJung

#54922 introduced a critical bug where the layout of an allocation is computed incorrectly, leading (at least) to a deallocation with a different size than the allocation.

This is easily demonstrated by cherry-picking RalfJung@c2e5933 and running ./x.py --stage 1 test src/liballoc (left is the correct layout, right is what we compute):

---- rc::tests::test_clone_from_slice stdout ----
thread 'rc::tests::test_clone_from_slice' panicked at 'assertion failed: `(left == right)`
  left: `Layout { size_: 32, align_: 8 }`,
 right: `Layout { size_: 28, align_: 8 }`', liballoc/rc.rs:683:9

---- rc::tests::test_copy_from_slice stdout ----
thread 'rc::tests::test_copy_from_slice' panicked at 'assertion failed: `(left == right)`
  left: `Layout { size_: 32, align_: 8 }`,
 right: `Layout { size_: 28, align_: 8 }`', liballoc/rc.rs:683:9

---- rc::tests::test_from_box_slice stdout ----
thread 'rc::tests::test_from_box_slice' panicked at 'assertion failed: `(left == right)`
  left: `Layout { size_: 32, align_: 8 }`,
 right: `Layout { size_: 28, align_: 8 }`', liballoc/rc.rs:683:9

---- rc::tests::test_from_box stdout ----
thread 'rc::tests::test_from_box' panicked at 'assertion failed: `(left == right)`
  left: `Layout { size_: 24, align_: 8 }`,
 right: `Layout { size_: 20, align_: 8 }`', liballoc/rc.rs:683:9

---- rc::tests::test_from_box_str stdout ----
thread 'rc::tests::test_from_box_str' panicked at 'assertion failed: `(left == right)`
  left: `Layout { size_: 24, align_: 8 }`,
 right: `Layout { size_: 19, align_: 8 }`', liballoc/rc.rs:683:9

---- rc::tests::test_from_box_trait stdout ----
thread 'rc::tests::test_from_box_trait' panicked at 'assertion failed: `(left == right)`
  left: `Layout { size_: 24, align_: 8 }`,
 right: `Layout { size_: 20, align_: 8 }`', liballoc/rc.rs:683:9

---- rc::tests::test_from_vec stdout ----
thread 'rc::tests::test_from_vec' panicked at 'assertion failed: `(left == right)`
  left: `Layout { size_: 32, align_: 8 }`,
 right: `Layout { size_: 28, align_: 8 }`', liballoc/rc.rs:683:9

---- rc::tests::test_from_str stdout ----
thread 'rc::tests::test_from_str' panicked at 'assertion failed: `(left == right)`
  left: `Layout { size_: 24, align_: 8 }`,
 right: `Layout { size_: 19, align_: 8 }`', liballoc/rc.rs:683:9

---- rc::tests::test_into_from_raw_unsized stdout ----
thread 'rc::tests::test_into_from_raw_unsized' panicked at 'assertion failed: `(left == right)`
  left: `Layout { size_: 24, align_: 8 }`,
 right: `Layout { size_: 19, align_: 8 }`', liballoc/rc.rs:683:9

---- sync::tests::test_clone_from_slice stdout ----
thread 'sync::tests::test_clone_from_slice' panicked at 'assertion failed: `(left == right)`
  left: `Layout { size_: 32, align_: 8 }`,
 right: `Layout { size_: 28, align_: 8 }`', liballoc/sync.rs:586:9

---- sync::tests::test_copy_from_slice stdout ----
thread 'sync::tests::test_copy_from_slice' panicked at 'assertion failed: `(left == right)`
  left: `Layout { size_: 32, align_: 8 }`,
 right: `Layout { size_: 28, align_: 8 }`', liballoc/sync.rs:586:9

---- sync::tests::test_from_box stdout ----
thread 'sync::tests::test_from_box' panicked at 'assertion failed: `(left == right)`
  left: `Layout { size_: 24, align_: 8 }`,
 right: `Layout { size_: 20, align_: 8 }`', liballoc/sync.rs:586:9

---- sync::tests::test_from_box_slice stdout ----
thread 'sync::tests::test_from_box_slice' panicked at 'assertion failed: `(left == right)`
  left: `Layout { size_: 32, align_: 8 }`,
 right: `Layout { size_: 28, align_: 8 }`', liballoc/sync.rs:586:9

---- sync::tests::test_from_box_str stdout ----
thread 'sync::tests::test_from_box_str' panicked at 'assertion failed: `(left == right)`
  left: `Layout { size_: 24, align_: 8 }`,
 right: `Layout { size_: 19, align_: 8 }`', liballoc/sync.rs:586:9

---- sync::tests::test_from_box_trait stdout ----
thread 'sync::tests::test_from_box_trait' panicked at 'assertion failed: `(left == right)`
  left: `Layout { size_: 24, align_: 8 }`,
 right: `Layout { size_: 20, align_: 8 }`', liballoc/sync.rs:586:9

---- sync::tests::test_from_str stdout ----
thread 'sync::tests::test_from_str' panicked at 'assertion failed: `(left == right)`
  left: `Layout { size_: 24, align_: 8 }`,
 right: `Layout { size_: 19, align_: 8 }`', liballoc/sync.rs:586:9

---- sync::tests::test_from_vec stdout ----
thread 'sync::tests::test_from_vec' panicked at 'assertion failed: `(left == right)`
  left: `Layout { size_: 32, align_: 8 }`,
 right: `Layout { size_: 28, align_: 8 }`', liballoc/sync.rs:586:9

---- sync::tests::test_into_from_raw_unsized stdout ----
thread 'sync::tests::test_into_from_raw_unsized' panicked at 'assertion failed: `(left == right)`
  left: `Layout { size_: 24, align_: 8 }`,
 right: `Layout { size_: 19, align_: 8 }`', liballoc/sync.rs:586:9

Cc @murarth

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions