Skip to content
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

Rollup of 6 pull requests #70878

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d730bf9
link with "libssp" on *-sun-solaris systems
jclulow Mar 31, 2020
2c9d857
Miri leak_report: do not report leaks of allocations that are reachab…
RalfJung Apr 4, 2020
fbdff51
avoid printing allocations twice
RalfJung Apr 4, 2020
aecaeab
share more alloc printing code between Miri and MIR dumping
RalfJung Apr 4, 2020
1f3e247
indicate better which kind of memory got leaked
RalfJung Apr 4, 2020
c8b83ba
Keep codegen units unmerged when building compiler builtins
tmiasko Apr 6, 2020
e1a36e8
Bump nomicon submodule
faern Apr 6, 2020
d0a78ea
Bump rust-by-example submodule
faern Apr 6, 2020
01b3293
Bump stdarch submodule
faern Apr 6, 2020
65e10e3
Use assoc const f32::NAN in liballoc
faern Apr 6, 2020
cf1c7ed
Use assoc float consts in libcore
faern Apr 6, 2020
ebcf1e7
Stop importing float module in libserialize
faern Apr 6, 2020
09b5d66
Stop importing float module in libtest
faern Apr 6, 2020
e4fc04b
Use usize::MAX as assoc const in liballoc
faern Apr 6, 2020
3e4396b
Use integer assoc consts in libcore
faern Apr 6, 2020
68b1af6
Don't import integer module in libstd
faern Apr 6, 2020
cf8df01
Use assoc integer constants in libserialize
faern Apr 6, 2020
f7778d3
Use assoc integer constants in librustc_*
faern Apr 6, 2020
e8339e8
Use split_at in slice's ToOwned::clone_into
cuviper Mar 20, 2020
b80fa76
Implement ToOwned::clone_into for CStr
cuviper Mar 20, 2020
f854070
Forward OsStr::clone_into to the inner Vec
cuviper Mar 20, 2020
c966511
Rollup merge of #70201 - cuviper:clone_into, r=dtolnay
Centril Apr 7, 2020
94d4c0e
Rollup merge of #70682 - jclulow:illumos-libssp, r=nagisa
Centril Apr 7, 2020
5b7a874
Rollup merge of #70762 - RalfJung:miri-leak-check, r=oli-obk
Centril Apr 7, 2020
ea29e7b
Rollup merge of #70846 - tmiasko:compiler-builtins-codegen-units, r=a…
Centril Apr 7, 2020
61cd420
Rollup merge of #70854 - faern:use-assoc-int-submodules, r=dtolnay
Centril Apr 7, 2020
17c5a81
Rollup merge of #70857 - faern:use-assoc-int-float-consts, r=dtolnay
Centril Apr 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
indicate better which kind of memory got leaked
  • Loading branch information
RalfJung committed Apr 4, 2020
commit 1f3e2478b2e7267034d30a76ef4d28791a57d925
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub trait AllocMap<K: Hash + Eq, V> {
/// and some use case dependent behaviour can instead be applied.
pub trait Machine<'mir, 'tcx>: Sized {
/// Additional memory kinds a machine wishes to distinguish from the builtin ones
type MemoryKind: ::std::fmt::Debug + MayLeak + Eq + 'static;
type MemoryKind: ::std::fmt::Debug + ::std::fmt::Display + MayLeak + Eq + 'static;

/// Tag tracked alongside every pointer. This is used to implement "Stacked Borrows"
/// <https://www.ralfj.de/blog/2018/08/07/stacked-borrows.html>.
Expand Down
26 changes: 15 additions & 11 deletions src/librustc_mir/interpret/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use std::borrow::Cow;
use std::collections::VecDeque;
use std::convert::TryFrom;
use std::fmt;
use std::ptr;

use rustc_ast::ast::Mutability;
Expand Down Expand Up @@ -46,6 +47,17 @@ impl<T: MayLeak> MayLeak for MemoryKind<T> {
}
}

impl<T: fmt::Display> fmt::Display for MemoryKind<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
MemoryKind::Stack => write!(f, "stack variable"),
MemoryKind::Vtable => write!(f, "vtable"),
MemoryKind::CallerLocation => write!(f, "caller location"),
MemoryKind::Machine(m) => write!(f, "{}", m),
}
}
}

/// Used by `get_size_and_align` to indicate whether the allocation needs to be live.
#[derive(Debug, Copy, Clone)]
pub enum AllocCheck {
Expand Down Expand Up @@ -259,7 +271,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {

if alloc_kind != kind {
throw_ub_format!(
"deallocating `{:?}` memory using `{:?}` deallocation operation",
"deallocating {} memory using {} deallocation operation",
alloc_kind,
kind
);
Expand Down Expand Up @@ -677,22 +689,14 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
match self.alloc_map.get(id) {
Some(&(kind, ref alloc)) => {
// normal alloc
match kind {
MemoryKind::Stack => eprint!(" (stack variable, "),
MemoryKind::Vtable => eprint!(" (vtable, "),
MemoryKind::CallerLocation => eprint!(" (caller_location, "),
MemoryKind::Machine(m) if Some(m) == M::GLOBAL_KIND => {
eprint!(" (global, ")
}
MemoryKind::Machine(m) => eprint!(" ({:?}, ", m),
};
eprint!(" ({}, ", kind);
write_allocation_track_relocs(self.tcx, &mut allocs_to_print, alloc);
}
None => {
// global alloc
match self.tcx.alloc_map.lock().get(id) {
Some(GlobalAlloc::Memory(alloc)) => {
eprint!(" (global, ");
eprint!(" (unchanged global, ");
write_allocation_track_relocs(self.tcx, &mut allocs_to_print, alloc);
}
Some(GlobalAlloc::Function(func)) => {
Expand Down