1 //! Main evaluator loop and setting up the initial stack frame.
2
3 use std::ffi::{OsStr, OsString};
4 use std::iter;
5 use std::panic::{self, AssertUnwindSafe};
6 use std::path::PathBuf;
7 use std::task::Poll;
8 use std::thread;
9
10 use log::info;
11 use rustc_middle::ty::Ty;
12
13 use crate::borrow_tracker::RetagFields;
14 use crate::diagnostics::report_leaks;
15 use rustc_data_structures::fx::FxHashSet;
16 use rustc_hir::def::Namespace;
17 use rustc_hir::def_id::DefId;
18 use rustc_middle::ty::{
19 self,
20 layout::{LayoutCx, LayoutOf},
21 TyCtxt,
22 };
23 use rustc_target::spec::abi::Abi;
24
25 use rustc_session::config::EntryFnType;
26
27 use crate::shims::tls;
28 use crate::*;
29
30 /// When the main thread would exit, we will yield to any other thread that is ready to execute.
31 /// But we must only do that a finite number of times, or a background thread running `loop {}`
32 /// will hang the program.
33 const MAIN_THREAD_YIELDS_AT_SHUTDOWN: u32 = 256;
34
35 #[derive(Copy, Clone, Debug, PartialEq)]
36 pub enum AlignmentCheck {
37 /// Do not check alignment.
38 None,
39 /// Check alignment "symbolically", i.e., using only the requested alignment for an allocation and not its real base address.
40 Symbolic,
41 /// Check alignment on the actual physical integer address.
42 Int,
43 }
44
45 #[derive(Copy, Clone, Debug, PartialEq)]
46 pub enum RejectOpWith {
47 /// Isolated op is rejected with an abort of the machine.
48 Abort,
49
50 /// If not Abort, miri returns an error for an isolated op.
51 /// Following options determine if user should be warned about such error.
52 /// Do not print warning about rejected isolated op.
53 NoWarning,
54
55 /// Print a warning about rejected isolated op, with backtrace.
56 Warning,
57
58 /// Print a warning about rejected isolated op, without backtrace.
59 WarningWithoutBacktrace,
60 }
61
62 #[derive(Copy, Clone, Debug, PartialEq)]
63 pub enum IsolatedOp {
64 /// Reject an op requiring communication with the host. By
65 /// default, miri rejects the op with an abort. If not, it returns
66 /// an error code, and prints a warning about it. Warning levels
67 /// are controlled by `RejectOpWith` enum.
68 Reject(RejectOpWith),
69
70 /// Execute op requiring communication with the host, i.e. disable isolation.
71 Allow,
72 }
73
74 #[derive(Copy, Clone, PartialEq, Eq)]
75 pub enum BacktraceStyle {
76 /// Prints a terser backtrace which ideally only contains relevant information.
77 Short,
78 /// Prints a backtrace with all possible information.
79 Full,
80 /// Prints only the frame that the error occurs in.
81 Off,
82 }
83
84 /// Configuration needed to spawn a Miri instance.
85 #[derive(Clone)]
86 pub struct MiriConfig {
87 /// The host environment snapshot to use as basis for what is provided to the interpreted program.
88 /// (This is still subject to isolation as well as `forwarded_env_vars`.)
89 pub env: Vec<(OsString, OsString)>,
90 /// Determine if validity checking is enabled.
91 pub validate: bool,
92 /// Determines if Stacked Borrows or Tree Borrows is enabled.
93 pub borrow_tracker: Option<BorrowTrackerMethod>,
94 /// Whether `core::ptr::Unique` receives special treatment.
95 /// If `true` then `Unique` is reborrowed with its own new tag and permission,
96 /// otherwise `Unique` is just another raw pointer.
97 pub unique_is_unique: bool,
98 /// Controls alignment checking.
99 pub check_alignment: AlignmentCheck,
100 /// Controls function [ABI](Abi) checking.
101 pub check_abi: bool,
102 /// Action for an op requiring communication with the host.
103 pub isolated_op: IsolatedOp,
104 /// Determines if memory leaks should be ignored.
105 pub ignore_leaks: bool,
106 /// Environment variables that should always be forwarded from the host.
107 pub forwarded_env_vars: Vec<String>,
108 /// Command-line arguments passed to the interpreted program.
109 pub args: Vec<String>,
110 /// The seed to use when non-determinism or randomness are required (e.g. ptr-to-int cast, `getrandom()`).
111 pub seed: Option<u64>,
112 /// The stacked borrows pointer ids to report about
113 pub tracked_pointer_tags: FxHashSet<BorTag>,
114 /// The stacked borrows call IDs to report about
115 pub tracked_call_ids: FxHashSet<CallId>,
116 /// The allocation ids to report about.
117 pub tracked_alloc_ids: FxHashSet<AllocId>,
118 /// Determine if data race detection should be enabled
119 pub data_race_detector: bool,
120 /// Determine if weak memory emulation should be enabled. Requires data race detection to be enabled
121 pub weak_memory_emulation: bool,
122 /// Track when an outdated (weak memory) load happens.
123 pub track_outdated_loads: bool,
124 /// Rate of spurious failures for compare_exchange_weak atomic operations,
125 /// between 0.0 and 1.0, defaulting to 0.8 (80% chance of failure).
126 pub cmpxchg_weak_failure_rate: f64,
127 /// If `Some`, enable the `measureme` profiler, writing results to a file
128 /// with the specified prefix.
129 pub measureme_out: Option<String>,
130 /// Panic when unsupported functionality is encountered.
131 pub panic_on_unsupported: bool,
132 /// Which style to use for printing backtraces.
133 pub backtrace_style: BacktraceStyle,
134 /// Which provenance to use for int2ptr casts
135 pub provenance_mode: ProvenanceMode,
136 /// Whether to ignore any output by the program. This is helpful when debugging miri
137 /// as its messages don't get intermingled with the program messages.
138 pub mute_stdout_stderr: bool,
139 /// The probability of the active thread being preempted at the end of each basic block.
140 pub preemption_rate: f64,
141 /// Report the current instruction being executed every N basic blocks.
142 pub report_progress: Option<u32>,
143 /// Whether Stacked Borrows and Tree Borrows retagging should recurse into fields of datatypes.
144 pub retag_fields: RetagFields,
145 /// The location of a shared object file to load when calling external functions
146 /// FIXME! consider allowing users to specify paths to multiple SO files, or to a directory
147 pub external_so_file: Option<PathBuf>,
148 /// Run a garbage collector for BorTags every N basic blocks.
149 pub gc_interval: u32,
150 /// The number of CPUs to be reported by miri.
151 pub num_cpus: u32,
152 /// Requires Miri to emulate pages of a certain size
153 pub page_size: Option<u64>,
154 /// Whether to collect a backtrace when each allocation is created, just in case it leaks.
155 pub collect_leak_backtraces: bool,
156 }
157
158 impl Default for MiriConfig {
default() -> MiriConfig159 fn default() -> MiriConfig {
160 MiriConfig {
161 env: vec![],
162 validate: true,
163 borrow_tracker: Some(BorrowTrackerMethod::StackedBorrows),
164 unique_is_unique: false,
165 check_alignment: AlignmentCheck::Int,
166 check_abi: true,
167 isolated_op: IsolatedOp::Reject(RejectOpWith::Abort),
168 ignore_leaks: false,
169 forwarded_env_vars: vec![],
170 args: vec![],
171 seed: None,
172 tracked_pointer_tags: FxHashSet::default(),
173 tracked_call_ids: FxHashSet::default(),
174 tracked_alloc_ids: FxHashSet::default(),
175 data_race_detector: true,
176 weak_memory_emulation: true,
177 track_outdated_loads: false,
178 cmpxchg_weak_failure_rate: 0.8, // 80%
179 measureme_out: None,
180 panic_on_unsupported: false,
181 backtrace_style: BacktraceStyle::Short,
182 provenance_mode: ProvenanceMode::Default,
183 mute_stdout_stderr: false,
184 preemption_rate: 0.01, // 1%
185 report_progress: None,
186 retag_fields: RetagFields::OnlyScalar,
187 external_so_file: None,
188 gc_interval: 10_000,
189 num_cpus: 1,
190 page_size: None,
191 collect_leak_backtraces: true,
192 }
193 }
194 }
195
196 /// The state of the main thread. Implementation detail of `on_main_stack_empty`.
197 #[derive(Default, Debug)]
198 enum MainThreadState {
199 #[default]
200 Running,
201 TlsDtors(tls::TlsDtorsState),
202 Yield {
203 remaining: u32,
204 },
205 Done,
206 }
207
208 impl MainThreadState {
on_main_stack_empty<'tcx>( &mut self, this: &mut MiriInterpCx<'_, 'tcx>, ) -> InterpResult<'tcx, Poll<()>>209 fn on_main_stack_empty<'tcx>(
210 &mut self,
211 this: &mut MiriInterpCx<'_, 'tcx>,
212 ) -> InterpResult<'tcx, Poll<()>> {
213 use MainThreadState::*;
214 match self {
215 Running => {
216 *self = TlsDtors(Default::default());
217 }
218 TlsDtors(state) =>
219 match state.on_stack_empty(this)? {
220 Poll::Pending => {} // just keep going
221 Poll::Ready(()) => {
222 // Give background threads a chance to finish by yielding the main thread a
223 // couple of times -- but only if we would also preempt threads randomly.
224 if this.machine.preemption_rate > 0.0 {
225 // There is a non-zero chance they will yield back to us often enough to
226 // make Miri terminate eventually.
227 *self = Yield { remaining: MAIN_THREAD_YIELDS_AT_SHUTDOWN };
228 } else {
229 // The other threads did not get preempted, so no need to yield back to
230 // them.
231 *self = Done;
232 }
233 }
234 },
235 Yield { remaining } =>
236 match remaining.checked_sub(1) {
237 None => *self = Done,
238 Some(new_remaining) => {
239 *remaining = new_remaining;
240 this.yield_active_thread();
241 }
242 },
243 Done => {
244 // Figure out exit code.
245 let ret_place = MPlaceTy::from_aligned_ptr(
246 this.machine.main_fn_ret_place.unwrap().ptr,
247 this.machine.layouts.isize,
248 );
249 let exit_code = this.read_target_isize(&ret_place.into())?;
250 // Need to call this ourselves since we are not going to return to the scheduler
251 // loop, and we want the main thread TLS to not show up as memory leaks.
252 this.terminate_active_thread()?;
253 // Stop interpreter loop.
254 throw_machine_stop!(TerminationInfo::Exit { code: exit_code, leak_check: true });
255 }
256 }
257 Ok(Poll::Pending)
258 }
259 }
260
261 /// Returns a freshly created `InterpCx`.
262 /// Public because this is also used by `priroda`.
create_ecx<'mir, 'tcx: 'mir>( tcx: TyCtxt<'tcx>, entry_id: DefId, entry_type: EntryFnType, config: &MiriConfig, ) -> InterpResult<'tcx, InterpCx<'mir, 'tcx, MiriMachine<'mir, 'tcx>>>263 pub fn create_ecx<'mir, 'tcx: 'mir>(
264 tcx: TyCtxt<'tcx>,
265 entry_id: DefId,
266 entry_type: EntryFnType,
267 config: &MiriConfig,
268 ) -> InterpResult<'tcx, InterpCx<'mir, 'tcx, MiriMachine<'mir, 'tcx>>> {
269 let param_env = ty::ParamEnv::reveal_all();
270 let layout_cx = LayoutCx { tcx, param_env };
271 let mut ecx = InterpCx::new(
272 tcx,
273 rustc_span::source_map::DUMMY_SP,
274 param_env,
275 MiriMachine::new(config, layout_cx),
276 );
277
278 // Some parts of initialization require a full `InterpCx`.
279 MiriMachine::late_init(&mut ecx, config, {
280 let mut state = MainThreadState::default();
281 // Cannot capture anything GC-relevant here.
282 Box::new(move |m| state.on_main_stack_empty(m))
283 })?;
284
285 // Make sure we have MIR. We check MIR for some stable monomorphic function in libcore.
286 let sentinel = ecx.try_resolve_path(&["core", "ascii", "escape_default"], Namespace::ValueNS);
287 if !matches!(sentinel, Some(s) if tcx.is_mir_available(s.def.def_id())) {
288 tcx.sess.fatal(
289 "the current sysroot was built without `-Zalways-encode-mir`, or libcore seems missing. \
290 Use `cargo miri setup` to prepare a sysroot that is suitable for Miri."
291 );
292 }
293
294 // Setup first stack frame.
295 let entry_instance = ty::Instance::mono(tcx, entry_id);
296
297 // First argument is constructed later, because it's skipped if the entry function uses #[start].
298
299 // Second argument (argc): length of `config.args`.
300 let argc = Scalar::from_target_usize(u64::try_from(config.args.len()).unwrap(), &ecx);
301 // Third argument (`argv`): created from `config.args`.
302 let argv = {
303 // Put each argument in memory, collect pointers.
304 let mut argvs = Vec::<Immediate<Provenance>>::new();
305 for arg in config.args.iter() {
306 // Make space for `0` terminator.
307 let size = u64::try_from(arg.len()).unwrap().checked_add(1).unwrap();
308 let arg_type = Ty::new_array(tcx,tcx.types.u8, size);
309 let arg_place =
310 ecx.allocate(ecx.layout_of(arg_type)?, MiriMemoryKind::Machine.into())?;
311 ecx.write_os_str_to_c_str(OsStr::new(arg), arg_place.ptr, size)?;
312 ecx.mark_immutable(&arg_place);
313 argvs.push(arg_place.to_ref(&ecx));
314 }
315 // Make an array with all these pointers, in the Miri memory.
316 let argvs_layout = ecx.layout_of(
317 Ty::new_array(tcx,Ty::new_imm_ptr(tcx,tcx.types.u8), u64::try_from(argvs.len()).unwrap()),
318 )?;
319 let argvs_place = ecx.allocate(argvs_layout, MiriMemoryKind::Machine.into())?;
320 for (idx, arg) in argvs.into_iter().enumerate() {
321 let place = ecx.mplace_field(&argvs_place, idx)?;
322 ecx.write_immediate(arg, &place.into())?;
323 }
324 ecx.mark_immutable(&argvs_place);
325 // A pointer to that place is the 3rd argument for main.
326 let argv = argvs_place.to_ref(&ecx);
327 // Store `argc` and `argv` for macOS `_NSGetArg{c,v}`.
328 {
329 let argc_place =
330 ecx.allocate(ecx.machine.layouts.isize, MiriMemoryKind::Machine.into())?;
331 ecx.write_scalar(argc, &argc_place.into())?;
332 ecx.mark_immutable(&argc_place);
333 ecx.machine.argc = Some(*argc_place);
334
335 let argv_place = ecx.allocate(
336 ecx.layout_of(Ty::new_imm_ptr(tcx,tcx.types.unit))?,
337 MiriMemoryKind::Machine.into(),
338 )?;
339 ecx.write_immediate(argv, &argv_place.into())?;
340 ecx.mark_immutable(&argv_place);
341 ecx.machine.argv = Some(*argv_place);
342 }
343 // Store command line as UTF-16 for Windows `GetCommandLineW`.
344 {
345 // Construct a command string with all the arguments.
346 let cmd_utf16: Vec<u16> = args_to_utf16_command_string(config.args.iter());
347
348 let cmd_type = Ty::new_array(tcx,tcx.types.u16, u64::try_from(cmd_utf16.len()).unwrap());
349 let cmd_place =
350 ecx.allocate(ecx.layout_of(cmd_type)?, MiriMemoryKind::Machine.into())?;
351 ecx.machine.cmd_line = Some(*cmd_place);
352 // Store the UTF-16 string. We just allocated so we know the bounds are fine.
353 for (idx, &c) in cmd_utf16.iter().enumerate() {
354 let place = ecx.mplace_field(&cmd_place, idx)?;
355 ecx.write_scalar(Scalar::from_u16(c), &place.into())?;
356 }
357 ecx.mark_immutable(&cmd_place);
358 }
359 argv
360 };
361
362 // Return place (in static memory so that it does not count as leak).
363 let ret_place = ecx.allocate(ecx.machine.layouts.isize, MiriMemoryKind::Machine.into())?;
364 ecx.machine.main_fn_ret_place = Some(*ret_place);
365 // Call start function.
366
367 match entry_type {
368 EntryFnType::Main { .. } => {
369 let start_id = tcx.lang_items().start_fn().unwrap();
370 let main_ret_ty = tcx.fn_sig(entry_id).no_bound_vars().unwrap().output();
371 let main_ret_ty = main_ret_ty.no_bound_vars().unwrap();
372 let start_instance = ty::Instance::resolve(
373 tcx,
374 ty::ParamEnv::reveal_all(),
375 start_id,
376 tcx.mk_substs(&[ty::subst::GenericArg::from(main_ret_ty)]),
377 )
378 .unwrap()
379 .unwrap();
380
381 let main_ptr = ecx.create_fn_alloc_ptr(FnVal::Instance(entry_instance));
382
383 // Inlining of `DEFAULT` from
384 // https://github.com/rust-lang/rust/blob/master/compiler/rustc_session/src/config/sigpipe.rs.
385 // Always using DEFAULT is okay since we don't support signals in Miri anyway.
386 let sigpipe = 2;
387
388 ecx.call_function(
389 start_instance,
390 Abi::Rust,
391 &[
392 Scalar::from_pointer(main_ptr, &ecx).into(),
393 argc.into(),
394 argv,
395 Scalar::from_u8(sigpipe).into(),
396 ],
397 Some(&ret_place.into()),
398 StackPopCleanup::Root { cleanup: true },
399 )?;
400 }
401 EntryFnType::Start => {
402 ecx.call_function(
403 entry_instance,
404 Abi::Rust,
405 &[argc.into(), argv],
406 Some(&ret_place.into()),
407 StackPopCleanup::Root { cleanup: true },
408 )?;
409 }
410 }
411
412 Ok(ecx)
413 }
414
415 /// Evaluates the entry function specified by `entry_id`.
416 /// Returns `Some(return_code)` if program executed completed.
417 /// Returns `None` if an evaluation error occurred.
418 #[allow(clippy::needless_lifetimes)]
eval_entry<'tcx>( tcx: TyCtxt<'tcx>, entry_id: DefId, entry_type: EntryFnType, config: MiriConfig, ) -> Option<i64>419 pub fn eval_entry<'tcx>(
420 tcx: TyCtxt<'tcx>,
421 entry_id: DefId,
422 entry_type: EntryFnType,
423 config: MiriConfig,
424 ) -> Option<i64> {
425 // Copy setting before we move `config`.
426 let ignore_leaks = config.ignore_leaks;
427
428 let mut ecx = match create_ecx(tcx, entry_id, entry_type, &config) {
429 Ok(v) => v,
430 Err(err) => {
431 let (kind, backtrace) = err.into_parts();
432 backtrace.print_backtrace();
433 panic!("Miri initialization error: {kind:?}")
434 }
435 };
436
437 // Perform the main execution.
438 let res: thread::Result<InterpResult<'_, !>> =
439 panic::catch_unwind(AssertUnwindSafe(|| ecx.run_threads()));
440 let res = res.unwrap_or_else(|panic_payload| {
441 ecx.handle_ice();
442 panic::resume_unwind(panic_payload)
443 });
444 let res = match res {
445 Err(res) => res,
446 // `Ok` can never happen
447 Ok(never) => match never {},
448 };
449
450 // Machine cleanup. Only do this if all threads have terminated; threads that are still running
451 // might cause Stacked Borrows errors (https://github.com/rust-lang/miri/issues/2396).
452 if ecx.have_all_terminated() {
453 // Even if all threads have terminated, we have to beware of data races since some threads
454 // might not have joined the main thread (https://github.com/rust-lang/miri/issues/2020,
455 // https://github.com/rust-lang/miri/issues/2508).
456 ecx.allow_data_races_all_threads_done();
457 EnvVars::cleanup(&mut ecx).expect("error during env var cleanup");
458 }
459
460 // Process the result.
461 let (return_code, leak_check) = report_error(&ecx, res)?;
462 if leak_check && !ignore_leaks {
463 // Check for thread leaks.
464 if !ecx.have_all_terminated() {
465 tcx.sess.err("the main thread terminated without waiting for all remaining threads");
466 tcx.sess.note_without_error("pass `-Zmiri-ignore-leaks` to disable this check");
467 return None;
468 }
469 // Check for memory leaks.
470 info!("Additional static roots: {:?}", ecx.machine.static_roots);
471 let leaks = ecx.find_leaked_allocations(&ecx.machine.static_roots);
472 if !leaks.is_empty() {
473 report_leaks(&ecx, leaks);
474 let leak_message = "the evaluated program leaked memory, pass `-Zmiri-ignore-leaks` to disable this check";
475 if ecx.machine.collect_leak_backtraces {
476 // If we are collecting leak backtraces, each leak is a distinct error diagnostic.
477 tcx.sess.note_without_error(leak_message);
478 } else {
479 // If we do not have backtraces, we just report an error without any span.
480 tcx.sess.err(leak_message);
481 };
482 // Ignore the provided return code - let the reported error
483 // determine the return code.
484 return None;
485 }
486 }
487 Some(return_code)
488 }
489
490 /// Turns an array of arguments into a Windows command line string.
491 ///
492 /// The string will be UTF-16 encoded and NUL terminated.
493 ///
494 /// Panics if the zeroth argument contains the `"` character because doublequotes
495 /// in `argv[0]` cannot be encoded using the standard command line parsing rules.
496 ///
497 /// Further reading:
498 /// * [Parsing C++ command-line arguments](https://docs.microsoft.com/en-us/cpp/cpp/main-function-command-line-args?view=msvc-160#parsing-c-command-line-arguments)
499 /// * [The C/C++ Parameter Parsing Rules](https://daviddeley.com/autohotkey/parameters/parameters.htm#WINCRULES)
args_to_utf16_command_string<I, T>(mut args: I) -> Vec<u16> where I: Iterator<Item = T>, T: AsRef<str>,500 fn args_to_utf16_command_string<I, T>(mut args: I) -> Vec<u16>
501 where
502 I: Iterator<Item = T>,
503 T: AsRef<str>,
504 {
505 // Parse argv[0]. Slashes aren't escaped. Literal double quotes are not allowed.
506 let mut cmd = {
507 let arg0 = if let Some(arg0) = args.next() {
508 arg0
509 } else {
510 return vec![0];
511 };
512 let arg0 = arg0.as_ref();
513 if arg0.contains('"') {
514 panic!("argv[0] cannot contain a doublequote (\") character");
515 } else {
516 // Always surround argv[0] with quotes.
517 let mut s = String::new();
518 s.push('"');
519 s.push_str(arg0);
520 s.push('"');
521 s
522 }
523 };
524
525 // Build the other arguments.
526 for arg in args {
527 let arg = arg.as_ref();
528 cmd.push(' ');
529 if arg.is_empty() {
530 cmd.push_str("\"\"");
531 } else if !arg.bytes().any(|c| matches!(c, b'"' | b'\t' | b' ')) {
532 // No quote, tab, or space -- no escaping required.
533 cmd.push_str(arg);
534 } else {
535 // Spaces and tabs are escaped by surrounding them in quotes.
536 // Quotes are themselves escaped by using backslashes when in a
537 // quoted block.
538 // Backslashes only need to be escaped when one or more are directly
539 // followed by a quote. Otherwise they are taken literally.
540
541 cmd.push('"');
542 let mut chars = arg.chars().peekable();
543 loop {
544 let mut nslashes = 0;
545 while let Some(&'\\') = chars.peek() {
546 chars.next();
547 nslashes += 1;
548 }
549
550 match chars.next() {
551 Some('"') => {
552 cmd.extend(iter::repeat('\\').take(nslashes * 2 + 1));
553 cmd.push('"');
554 }
555 Some(c) => {
556 cmd.extend(iter::repeat('\\').take(nslashes));
557 cmd.push(c);
558 }
559 None => {
560 cmd.extend(iter::repeat('\\').take(nslashes * 2));
561 break;
562 }
563 }
564 }
565 cmd.push('"');
566 }
567 }
568
569 if cmd.contains('\0') {
570 panic!("interior null in command line arguments");
571 }
572 cmd.encode_utf16().chain(iter::once(0)).collect()
573 }
574
575 #[cfg(test)]
576 mod tests {
577 use super::*;
578 #[test]
579 #[should_panic(expected = "argv[0] cannot contain a doublequote (\") character")]
windows_argv0_panic_on_quote()580 fn windows_argv0_panic_on_quote() {
581 args_to_utf16_command_string(["\""].iter());
582 }
583 #[test]
windows_argv0_no_escape()584 fn windows_argv0_no_escape() {
585 // Ensure that a trailing backslash in argv[0] is not escaped.
586 let cmd = String::from_utf16_lossy(&args_to_utf16_command_string(
587 [r"C:\Program Files\", "arg1", "arg 2", "arg \" 3"].iter(),
588 ));
589 assert_eq!(cmd.trim_end_matches('\0'), r#""C:\Program Files\" arg1 "arg 2" "arg \" 3""#);
590 }
591 }
592