|
3 | 3 |
|
4 | 4 | use std::any::Any;
|
5 | 5 | use std::borrow::Cow;
|
6 |
| -use std::cell::RefCell; |
| 6 | +use std::cell::{Cell, RefCell}; |
7 | 7 | use std::collections::hash_map::Entry;
|
8 | 8 | use std::path::Path;
|
9 | 9 | use std::{fmt, process};
|
@@ -595,6 +595,21 @@ pub struct MiriMachine<'tcx> {
|
595 | 595 |
|
596 | 596 | /// A cache of "data range" computations for unions (i.e., the offsets of non-padding bytes).
|
597 | 597 | union_data_ranges: FxHashMap<Ty<'tcx>, RangeSet>,
|
| 598 | + |
| 599 | + /// Caches the sanity-checks for various pthread primitives. |
| 600 | + pub(crate) pthread_mutex_sanity: Cell<bool>, |
| 601 | + pub(crate) pthread_rwlock_sanity: Cell<bool>, |
| 602 | + pub(crate) pthread_condvar_sanity: Cell<bool>, |
| 603 | + |
| 604 | + /// Remembers whether we already warned about an extern type with Stacked Borrows. |
| 605 | + pub(crate) sb_extern_type_warned: Cell<bool>, |
| 606 | + /// Remember whether we already warned about sharing memory with a native call. |
| 607 | + #[cfg(unix)] |
| 608 | + pub(crate) native_call_mem_warned: Cell<bool>, |
| 609 | + /// Remembers which shims have already shown the warning about erroring in isolation. |
| 610 | + pub(crate) reject_in_isolation_warned: RefCell<FxHashSet<String>>, |
| 611 | + /// Remembers which int2ptr casts we have already warned about. |
| 612 | + pub(crate) int2ptr_warned: RefCell<FxHashSet<Span>>, |
598 | 613 | }
|
599 | 614 |
|
600 | 615 | impl<'tcx> MiriMachine<'tcx> {
|
@@ -732,6 +747,14 @@ impl<'tcx> MiriMachine<'tcx> {
|
732 | 747 | const_cache: RefCell::new(FxHashMap::default()),
|
733 | 748 | symbolic_alignment: RefCell::new(FxHashMap::default()),
|
734 | 749 | union_data_ranges: FxHashMap::default(),
|
| 750 | + pthread_mutex_sanity: Cell::new(false), |
| 751 | + pthread_rwlock_sanity: Cell::new(false), |
| 752 | + pthread_condvar_sanity: Cell::new(false), |
| 753 | + sb_extern_type_warned: Cell::new(false), |
| 754 | + #[cfg(unix)] |
| 755 | + native_call_mem_warned: Cell::new(false), |
| 756 | + reject_in_isolation_warned: Default::default(), |
| 757 | + int2ptr_warned: Default::default(), |
735 | 758 | }
|
736 | 759 | }
|
737 | 760 |
|
@@ -844,6 +867,14 @@ impl VisitProvenance for MiriMachine<'_> {
|
844 | 867 | const_cache: _,
|
845 | 868 | symbolic_alignment: _,
|
846 | 869 | union_data_ranges: _,
|
| 870 | + pthread_mutex_sanity: _, |
| 871 | + pthread_rwlock_sanity: _, |
| 872 | + pthread_condvar_sanity: _, |
| 873 | + sb_extern_type_warned: _, |
| 874 | + #[cfg(unix)] |
| 875 | + native_call_mem_warned: _, |
| 876 | + reject_in_isolation_warned: _, |
| 877 | + int2ptr_warned: _, |
847 | 878 | } = self;
|
848 | 879 |
|
849 | 880 | threads.visit_provenance(visit);
|
|
0 commit comments