summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2019-08-08 22:42:31 +0800
committerJohn Hodge <tpg@ucc.asn.au>2019-08-08 22:42:31 +0800
commitdd5c8ea810f8fb95fae71ae16d45dbff945651b7 (patch)
treeaec06d914dc5f7264dd1f490d4c7bc9ace0974b8
parentc1fe76bfbe373207c531519a9345cafb4166c667 (diff)
downloadmrust-dd5c8ea810f8fb95fae71ae16d45dbff945651b7.tar.gz
Standalone MIRI - Downgrade an error based on observed patterns
-rw-r--r--tools/standalone_miri/hir_sim.cpp1
-rw-r--r--tools/standalone_miri/value.cpp7
-rw-r--r--tools/standalone_miri/value.hpp11
3 files changed, 14 insertions, 5 deletions
diff --git a/tools/standalone_miri/hir_sim.cpp b/tools/standalone_miri/hir_sim.cpp
index a666dfee..dc03ca8a 100644
--- a/tools/standalone_miri/hir_sim.cpp
+++ b/tools/standalone_miri/hir_sim.cpp
@@ -157,6 +157,7 @@ size_t HIR::TypeRef::get_align(size_t ofs) const
case RawType::ISize:
return POINTER_SIZE;
}
+ throw "";
}
}
bool HIR::TypeRef::has_slice_meta(size_t& out_inner_size) const
diff --git a/tools/standalone_miri/value.cpp b/tools/standalone_miri/value.cpp
index 7c3e205a..8860c8d9 100644
--- a/tools/standalone_miri/value.cpp
+++ b/tools/standalone_miri/value.cpp
@@ -25,7 +25,7 @@ namespace {
::std::ostream& operator<<(::std::ostream& os, const Allocation* x)
{
- os << "A(" << static_cast<const void*>(x) << " " << x->tag() /*<< " +" << x->size()*/ << ")";
+ os << "A(#" << x->m_index << " " << x->tag() /*<< " +" << x->size()*/ << ")";
return os;
}
@@ -61,9 +61,12 @@ bool FfiLayout::is_valid_read(size_t o, size_t s) const
return true;
}
+uint64_t Allocation::s_next_index = 0;
+
AllocationHandle Allocation::new_alloc(size_t size, ::std::string tag)
{
Allocation* rv = new Allocation();
+ rv->m_index = s_next_index++;
rv->m_tag = ::std::move(tag);
rv->refcount = 1;
rv->m_size = size;
@@ -530,7 +533,7 @@ void Allocation::write_bytes(size_t ofs, const void* src, size_t count)
if(count == 0)
return ;
- TRACE_FUNCTION_R("Allocation::write_bytes " << this << " " << ofs << "+" << count, *this);
+ //TRACE_FUNCTION_R("Allocation::write_bytes " << this << " " << ofs << "+" << count, *this);
if( !in_bounds(ofs, count, this->size()) ) {
LOG_ERROR("Out of bounds write, " << ofs << "+" << count << " > " << this->size());
throw "ERROR";
diff --git a/tools/standalone_miri/value.hpp b/tools/standalone_miri/value.hpp
index ab7add8c..a0350681 100644
--- a/tools/standalone_miri/value.hpp
+++ b/tools/standalone_miri/value.hpp
@@ -247,9 +247,13 @@ class Allocation:
public ValueCommonWrite
{
friend class AllocationHandle;
+
+ static uint64_t s_next_index;
+
::std::string m_tag;
size_t refcount;
size_t m_size;
+ uint64_t m_index;
// TODO: Read-only flag?
bool is_freed = false;
@@ -296,6 +300,7 @@ public:
void write_ptr(size_t ofs, size_t ptr_ofs, RelocationPtr reloc) override;
void set_reloc(size_t ofs, size_t len, RelocationPtr reloc);
+ friend ::std::ostream& operator<<(::std::ostream& os, const Allocation* x);
};
extern ::std::ostream& operator<<(::std::ostream& os, const Allocation& x);
@@ -389,19 +394,19 @@ struct ValueRef:
case RelocationPtr::Ty::Allocation:
if( !in_bounds(ofs, size, m_alloc.alloc().size()) )
{
- LOG_ERROR("ValueRef exceeds bounds of " << m_alloc << " - " << ofs << "+" << size << " > " << m_alloc.alloc().size());
+ LOG_NOTICE("ValueRef exceeds bounds of " << m_alloc << " - " << ofs << "+" << size << " > " << m_alloc.alloc().size());
}
break;
case RelocationPtr::Ty::StdString:
if( !in_bounds(ofs, size, m_alloc.str().size()) )
{
- LOG_ERROR("ValueRef exceeds bounds of string - " << ofs << "+" << size << " > " << m_alloc.str().size());
+ LOG_NOTICE("ValueRef exceeds bounds of string - " << ofs << "+" << size << " > " << m_alloc.str().size());
}
break;
case RelocationPtr::Ty::FfiPointer:
if( !in_bounds(ofs, size, m_alloc.ffi().get_size()) )
{
- LOG_ERROR("ValueRef exceeds bounds of FFI buffer - " << ofs << "+" << size << " > " << m_alloc.ffi().get_size());
+ LOG_NOTICE("ValueRef exceeds bounds of FFI buffer - " << ofs << "+" << size << " > " << m_alloc.ffi().get_size());
}
break;
default: