Skip to content

Commit b350c80

Browse files
committed
add backtics back in isolation error message
1 parent 044c9ca commit b350c80

File tree

7 files changed

+36
-38
lines changed

7 files changed

+36
-38
lines changed

src/shims/env.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
293293
let target_os = &this.tcx.sess.target.target.target_os;
294294
assert!(target_os == "linux" || target_os == "macos", "`getcwd` is only available for the UNIX target family");
295295

296-
this.check_no_isolation("getcwd")?;
296+
this.check_no_isolation("`getcwd`")?;
297297

298298
let buf = this.read_scalar(buf_op)?.check_init()?;
299299
let size = this.read_scalar(size_op)?.to_machine_usize(&*this.tcx)?;
@@ -320,7 +320,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
320320
let this = self.eval_context_mut();
321321
this.assert_target_os("windows", "GetCurrentDirectoryW");
322322

323-
this.check_no_isolation("GetCurrentDirectoryW")?;
323+
this.check_no_isolation("`GetCurrentDirectoryW`")?;
324324

325325
let size = u64::from(this.read_scalar(size_op)?.to_u32()?);
326326
let buf = this.read_scalar(buf_op)?.check_init()?;
@@ -339,7 +339,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
339339
let target_os = &this.tcx.sess.target.target.target_os;
340340
assert!(target_os == "linux" || target_os == "macos", "`getcwd` is only available for the UNIX target family");
341341

342-
this.check_no_isolation("chdir")?;
342+
this.check_no_isolation("`chdir`")?;
343343

344344
let path = this.read_path_from_c_str(this.read_scalar(path_op)?.check_init()?)?;
345345

@@ -360,7 +360,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
360360
let this = self.eval_context_mut();
361361
this.assert_target_os("windows", "SetCurrentDirectoryW");
362362

363-
this.check_no_isolation("SetCurrentDirectoryW")?;
363+
this.check_no_isolation("`SetCurrentDirectoryW`")?;
364364

365365
let path = this.read_path_from_wide_str(this.read_scalar(path_op)?.check_init()?)?;
366366

src/shims/posix/fs.rs

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl FileDescriptor for io::Stdin {
9090
fn read<'tcx>(&mut self, communicate_allowed: bool, bytes: &mut [u8]) -> InterpResult<'tcx, io::Result<usize>> {
9191
if !communicate_allowed {
9292
// We want isolation mode to be deterministic, so we have to disallow all reads, even stdin.
93-
helpers::isolation_error("read")?;
93+
helpers::isolation_error("`read` from stdin")?;
9494
}
9595
Ok(Read::read(self, bytes))
9696
}
@@ -417,7 +417,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
417417
) -> InterpResult<'tcx, i32> {
418418
let this = self.eval_context_mut();
419419

420-
this.check_no_isolation("open")?;
420+
this.check_no_isolation("`open`")?;
421421

422422
let flag = this.read_scalar(flag_op)?.to_i32()?;
423423

@@ -510,7 +510,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
510510
) -> InterpResult<'tcx, i32> {
511511
let this = self.eval_context_mut();
512512

513-
this.check_no_isolation("fcntl")?;
513+
this.check_no_isolation("`fcntl`")?;
514514

515515
if args.len() < 2 {
516516
throw_ub_format!("incorrect number of arguments for fcntl: got {}, expected at least 2", args.len());
@@ -574,8 +574,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
574574
fn close(&mut self, fd_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
575575
let this = self.eval_context_mut();
576576

577-
this.check_no_isolation("close")?;
578-
579577
let fd = this.read_scalar(fd_op)?.to_i32()?;
580578

581579
if let Some(file_descriptor) = this.machine.file_handler.handles.remove(&fd) {
@@ -709,7 +707,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
709707
fn unlink(&mut self, path_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
710708
let this = self.eval_context_mut();
711709

712-
this.check_no_isolation("unlink")?;
710+
this.check_no_isolation("`unlink`")?;
713711

714712
let path = this.read_path_from_c_str(this.read_scalar(path_op)?.check_init()?)?;
715713

@@ -739,7 +737,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
739737

740738
let this = self.eval_context_mut();
741739

742-
this.check_no_isolation("symlink")?;
740+
this.check_no_isolation("`symlink`")?;
743741

744742
let target = this.read_path_from_c_str(this.read_scalar(target_op)?.check_init()?)?;
745743
let linkpath = this.read_path_from_c_str(this.read_scalar(linkpath_op)?.check_init()?)?;
@@ -755,7 +753,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
755753
) -> InterpResult<'tcx, i32> {
756754
let this = self.eval_context_mut();
757755
this.assert_target_os("macos", "stat");
758-
this.check_no_isolation("stat")?;
756+
this.check_no_isolation("`stat`")?;
759757
// `stat` always follows symlinks.
760758
this.macos_stat_or_lstat(true, path_op, buf_op)
761759
}
@@ -768,7 +766,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
768766
) -> InterpResult<'tcx, i32> {
769767
let this = self.eval_context_mut();
770768
this.assert_target_os("macos", "lstat");
771-
this.check_no_isolation("lstat")?;
769+
this.check_no_isolation("`lstat`")?;
772770
this.macos_stat_or_lstat(false, path_op, buf_op)
773771
}
774772

@@ -780,7 +778,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
780778
let this = self.eval_context_mut();
781779

782780
this.assert_target_os("macos", "fstat");
783-
this.check_no_isolation("fstat")?;
781+
this.check_no_isolation("`fstat`")?;
784782

785783
let fd = this.read_scalar(fd_op)?.to_i32()?;
786784

@@ -802,7 +800,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
802800
let this = self.eval_context_mut();
803801

804802
this.assert_target_os("linux", "statx");
805-
this.check_no_isolation("statx")?;
803+
this.check_no_isolation("`statx`")?;
806804

807805
let statxbuf_scalar = this.read_scalar(statxbuf_op)?.check_init()?;
808806
let pathname_scalar = this.read_scalar(pathname_op)?.check_init()?;
@@ -961,7 +959,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
961959
) -> InterpResult<'tcx, i32> {
962960
let this = self.eval_context_mut();
963961

964-
this.check_no_isolation("rename")?;
962+
this.check_no_isolation("`rename`")?;
965963

966964
let oldpath_scalar = this.read_scalar(oldpath_op)?.check_init()?;
967965
let newpath_scalar = this.read_scalar(newpath_op)?.check_init()?;
@@ -987,7 +985,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
987985
) -> InterpResult<'tcx, i32> {
988986
let this = self.eval_context_mut();
989987

990-
this.check_no_isolation("mkdir")?;
988+
this.check_no_isolation("`mkdir`")?;
991989

992990
#[cfg_attr(not(unix), allow(unused_variables))]
993991
let mode = if this.tcx.sess.target.target.target_os == "macos" {
@@ -1020,7 +1018,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
10201018
) -> InterpResult<'tcx, i32> {
10211019
let this = self.eval_context_mut();
10221020

1023-
this.check_no_isolation("rmdir")?;
1021+
this.check_no_isolation("`rmdir`")?;
10241022

10251023
let path = this.read_path_from_c_str(this.read_scalar(path_op)?.check_init()?)?;
10261024

@@ -1032,7 +1030,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
10321030
fn opendir(&mut self, name_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, Scalar<Tag>> {
10331031
let this = self.eval_context_mut();
10341032

1035-
this.check_no_isolation("opendir")?;
1033+
this.check_no_isolation("`opendir`")?;
10361034

10371035
let name = this.read_path_from_c_str(this.read_scalar(name_op)?.check_init()?)?;
10381036

@@ -1063,7 +1061,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
10631061
let this = self.eval_context_mut();
10641062

10651063
this.assert_target_os("linux", "readdir64_r");
1066-
this.check_no_isolation("readdir64_r")?;
1064+
this.check_no_isolation("`readdir64_r`")?;
10671065

10681066
let dirp = this.read_scalar(dirp_op)?.to_machine_usize(this)?;
10691067

@@ -1150,7 +1148,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
11501148
let this = self.eval_context_mut();
11511149

11521150
this.assert_target_os("macos", "readdir_r");
1153-
this.check_no_isolation("readdir_r")?;
1151+
this.check_no_isolation("`readdir_r`")?;
11541152

11551153
let dirp = this.read_scalar(dirp_op)?.to_machine_usize(this)?;
11561154

@@ -1233,7 +1231,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
12331231
fn closedir(&mut self, dirp_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
12341232
let this = self.eval_context_mut();
12351233

1236-
this.check_no_isolation("closedir")?;
1234+
this.check_no_isolation("`closedir`")?;
12371235

12381236
let dirp = this.read_scalar(dirp_op)?.to_machine_usize(this)?;
12391237

@@ -1252,7 +1250,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
12521250
) -> InterpResult<'tcx, i32> {
12531251
let this = self.eval_context_mut();
12541252

1255-
this.check_no_isolation("ftruncate64")?;
1253+
this.check_no_isolation("`ftruncate64`")?;
12561254

12571255
let fd = this.read_scalar(fd_op)?.to_i32()?;
12581256
let length = this.read_scalar(length_op)?.to_i64()?;
@@ -1287,7 +1285,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
12871285

12881286
let this = self.eval_context_mut();
12891287

1290-
this.check_no_isolation("fsync")?;
1288+
this.check_no_isolation("`fsync`")?;
12911289

12921290
let fd = this.read_scalar(fd_op)?.to_i32()?;
12931291
if let Some(file_descriptor) = this.machine.file_handler.handles.get(&fd) {
@@ -1303,7 +1301,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
13031301
fn fdatasync(&mut self, fd_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
13041302
let this = self.eval_context_mut();
13051303

1306-
this.check_no_isolation("fdatasync")?;
1304+
this.check_no_isolation("`fdatasync`")?;
13071305

13081306
let fd = this.read_scalar(fd_op)?.to_i32()?;
13091307
if let Some(file_descriptor) = this.machine.file_handler.handles.get(&fd) {
@@ -1325,7 +1323,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
13251323
) -> InterpResult<'tcx, i32> {
13261324
let this = self.eval_context_mut();
13271325

1328-
this.check_no_isolation("sync_file_range")?;
1326+
this.check_no_isolation("`sync_file_range`")?;
13291327

13301328
let fd = this.read_scalar(fd_op)?.to_i32()?;
13311329
let offset = this.read_scalar(offset_op)?.to_i64()?;

src/shims/posix/linux/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ pub fn futex<'tcx>(
5555
let timeout_time = if this.is_null(this.read_scalar(timeout)?.check_init()?)? {
5656
None
5757
} else {
58+
this.check_no_isolation("`syscall(SYS_FUTEX, op=FUTEX_WAIT)` with timeout")?;
5859
let duration = match this.read_timespec(timeout)? {
5960
Some(duration) => duration,
6061
None => {
@@ -64,7 +65,6 @@ pub fn futex<'tcx>(
6465
return Ok(());
6566
}
6667
};
67-
this.check_no_isolation("FUTEX_WAIT with timeout")?;
6868
Some(if op & futex_realtime != 0 {
6969
Time::RealTime(SystemTime::now().checked_add(duration).unwrap())
7070
} else {

src/shims/posix/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
690690
) -> InterpResult<'tcx> {
691691
let this = self.eval_context_mut();
692692

693-
this.check_no_isolation("pthread_cond_timedwait")?;
693+
this.check_no_isolation("`pthread_cond_timedwait`")?;
694694

695695
let id = cond_get_or_create_id(this, cond_op)?;
696696
let mutex_id = mutex_get_or_create_id(this, mutex_op)?;

src/shims/time.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
2222
let this = self.eval_context_mut();
2323

2424
this.assert_target_os("linux", "clock_gettime");
25-
this.check_no_isolation("clock_gettime")?;
25+
this.check_no_isolation("`clock_gettime`")?;
2626

2727
let clk_id = this.read_scalar(clk_id_op)?.to_i32()?;
2828
let tp = this.deref_operand(tp_op)?;
@@ -60,7 +60,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
6060
let this = self.eval_context_mut();
6161

6262
this.assert_target_os("macos", "gettimeofday");
63-
this.check_no_isolation("gettimeofday")?;
63+
this.check_no_isolation("`gettimeofday`")?;
6464

6565
// Using tz is obsolete and should always be null
6666
let tz = this.read_scalar(tz_op)?.check_init()?;
@@ -91,7 +91,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
9191
let this = self.eval_context_mut();
9292

9393
this.assert_target_os("windows", "GetSystemTimeAsFileTime");
94-
this.check_no_isolation("GetSystemTimeAsFileTime")?;
94+
this.check_no_isolation("`GetSystemTimeAsFileTime`")?;
9595

9696
let NANOS_PER_SEC = this.eval_windows_u64("time", "NANOS_PER_SEC")?;
9797
let INTERVALS_PER_SEC = this.eval_windows_u64("time", "INTERVALS_PER_SEC")?;
@@ -119,7 +119,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
119119
let this = self.eval_context_mut();
120120

121121
this.assert_target_os("windows", "QueryPerformanceCounter");
122-
this.check_no_isolation("QueryPerformanceCounter")?;
122+
this.check_no_isolation("`QueryPerformanceCounter`")?;
123123

124124
// QueryPerformanceCounter uses a hardware counter as its basis.
125125
// Miri will emulate a counter with a resolution of 1 nanosecond.
@@ -135,7 +135,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
135135
let this = self.eval_context_mut();
136136

137137
this.assert_target_os("windows", "QueryPerformanceFrequency");
138-
this.check_no_isolation("QueryPerformanceFrequency")?;
138+
this.check_no_isolation("`QueryPerformanceFrequency`")?;
139139

140140
// Retrieves the frequency of the hardware performance counter.
141141
// The frequency of the performance counter is fixed at system boot and
@@ -150,7 +150,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
150150
let this = self.eval_context_ref();
151151

152152
this.assert_target_os("macos", "mach_absolute_time");
153-
this.check_no_isolation("mach_absolute_time")?;
153+
this.check_no_isolation("`mach_absolute_time`")?;
154154

155155
// This returns a u64, with time units determined dynamically by `mach_timebase_info`.
156156
// We return plain nanoseconds.
@@ -163,7 +163,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
163163
let this = self.eval_context_mut();
164164

165165
this.assert_target_os("macos", "mach_timebase_info");
166-
this.check_no_isolation("mach_timebase_info")?;
166+
this.check_no_isolation("`mach_timebase_info`")?;
167167

168168
let info = this.deref_operand(info_op)?;
169169

@@ -188,7 +188,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
188188

189189
let this = self.eval_context_mut();
190190

191-
this.check_no_isolation("nanosleep")?;
191+
this.check_no_isolation("`nanosleep`")?;
192192

193193
let duration = match this.read_timespec(req_op)? {
194194
Some(duration) => duration,

tests/compile-fail/fs/isolated_file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ignore-windows: File handling is not implemented yet
2-
// error-pattern: open not available when isolation is enabled
2+
// error-pattern: `open` not available when isolation is enabled
33

44
fn main() {
55
let _file = std::fs::File::open("file.txt").unwrap();

tests/compile-fail/fs/isolated_stdin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ extern crate libc;
77
fn main() -> std::io::Result<()> {
88
let mut bytes = [0u8; 512];
99
unsafe {
10-
libc::read(0, bytes.as_mut_ptr() as *mut libc::c_void, 512); //~ ERROR read not available when isolation is enabled
10+
libc::read(0, bytes.as_mut_ptr() as *mut libc::c_void, 512); //~ ERROR `read` from stdin not available when isolation is enabled
1111
}
1212
Ok(())
1313
}

0 commit comments

Comments
 (0)