Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upWrong size passed to free in issue-26709.rs run-pass test (yielding jemalloc assert fail) #27023
Comments
This comment has been minimized.
This comment has been minimized.
|
I also reproduce this running
|
steveklabnik
added
A-testsuite
A-build
labels
Jul 16, 2015
This comment has been minimized.
This comment has been minimized.
|
I can reproduce this as well on my Mac. (After applying #27139 to get around debuginfo issues, I then hit this bug; configure flags |
pnkfelix
added a commit
to pnkfelix/rust
that referenced
this issue
Jul 20, 2015
pnkfelix
changed the title
issue-26709.rs run-pass test fails with jemalloc assertion
jemalloc assert fail in issue-26709.rs run-pass test
Jul 20, 2015
pnkfelix
added
the
I-crash
label
Jul 20, 2015
This comment has been minimized.
This comment has been minimized.
|
(flagging as |
This comment has been minimized.
This comment has been minimized.
|
Looks like this is indeed a memory unsafety bug. We're allocating a chunk of memory with a size of 16 bytes and then deallocating it with the size of 20 bytes. This was never found because jemalloc assertions are normally disabled, but To see this in action, this program will abort because the assertion in #![feature(no_std, lang_items, start, box_syntax, unsize, unique, core_prelude)]
#![feature(core, coerce_unsized, core_intrinsics, libc, linkage)]
#![no_std]
#![allow(improper_ctypes)]
#[macro_use]
extern crate core;
extern crate libc;
use core::prelude::*;
use core::ptr::Unique;
use core::marker::Unsize;
use core::ops::CoerceUnsized;
struct Wrapper<'a, T: ?Sized>(&'a mut i32, T);
impl<'a, T: ?Sized> Drop for Wrapper<'a, T> {
fn drop(&mut self) {}
}
#[lang = "owned_box"]
struct Box<T>(Unique<T>);
impl<T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
#[start]
fn start(_argc: isize, _argv: *const *const u8) -> isize {
let mut x = 3;
let wrapper: Box<Wrapper<i32>> = box Wrapper(&mut x, 123);
let _: Box<Wrapper<Send>> = wrapper;
0
}
#[lang = "exchange_malloc"]
unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
assert_eq!(size, 16);
assert_eq!(align, 8);
extern {
fn malloc(size: usize) -> *mut u8;
}
malloc(size)
}
#[lang = "exchange_free"]
unsafe fn exchange_free(ptr: *mut u8, old_size: usize, align: usize) {
assert_eq!(old_size, 16);
assert_eq!(align, 8);
extern {
fn free(ptr: *mut u8);
}
free(ptr)
}
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
#[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "panic_fmt"]
#[linkage = "external"]
pub fn panic_fmt() -> ! {
unsafe { core::intrinsics::abort() }
}Nominating as this seems like a minor codegen bug (perhaps related to the warning that's printed), but I don't think that it's too too urgent to fix immediately. |
alexcrichton
changed the title
jemalloc assert fail in issue-26709.rs run-pass test
Wrong size passed to free in issue-26709.rs run-pass test
Jul 20, 2015
This comment has been minimized.
This comment has been minimized.
|
Also updated the title a bit. |
alexcrichton
added
I-nominated
T-compiler
labels
Jul 20, 2015
pnkfelix
referenced this issue
Jul 21, 2015
Closed
Buildbot Request: Add one `--enable-debug --enable-optimize` bot that at least bootstraps (no tests) #27010
pnkfelix
changed the title
Wrong size passed to free in issue-26709.rs run-pass test
Wrong size passed to free in issue-26709.rs run-pass test (yielding jemalloc assert fail)
Jul 21, 2015
This comment has been minimized.
This comment has been minimized.
|
The testcase can be simplified by just using size_of_val: struct Wrapper<'a, T: ?Sized>(&'a mut i32, T);
impl<'a, T: ?Sized> Drop for Wrapper<'a, T> {
fn drop(&mut self) {}
}
fn main() {
let mut x = 3;
let wrapper: Box<Wrapper<i32>> = Box::new(Wrapper(&mut x, 123));
assert_eq!(std::mem::size_of_val(&*wrapper), 16);
let wrapper2: Box<Wrapper<Send>> = wrapper;
assert_eq!(std::mem::size_of_val(&*wrapper2), 16); // currently fails
}This is essentially the same as issue #26403. |
pnkfelix
referenced this issue
Jul 24, 2015
Closed
When DST struct's last field is misaligned, memory access generated are for the wrong address #26403
pnkfelix
added a commit
to pnkfelix/rust
that referenced
this issue
Jul 28, 2015
pnkfelix
referenced this issue
Jul 28, 2015
Merged
Fix DST size_of_val and align_of_val computations #27351
pnkfelix
added a commit
to pnkfelix/rust
that referenced
this issue
Jul 29, 2015
bors
added a commit
that referenced
this issue
Aug 4, 2015
This comment has been minimized.
This comment has been minimized.
|
I believe this was fixed in #27351 |
alexcrichton
closed this
Aug 13, 2015
This comment has been minimized.
This comment has been minimized.
|
The following prints |
nagisa commentedJul 13, 2015
After
./configure --enable-rpath --disable-clang --disable-libcpp --enable-llvm-assertions --release-channel=dev --enable-debug --enable-optimizeon linux, running tests will fail with:I should make it clear I have no minimal reproduction and am not even sure whether configure flags. my system configuration or any local state have anything to do with reproducability.