@@ -15,6 +15,9 @@ use crate::alloc::isolated_alloc::IsolatedAlloc;
1515/// need to ensure that either (a) only one `MiriMachine` is performing an FFI call 
1616/// at any given time, or (b) there are distinct supervisor and child processes for 
1717/// each machine. The former was chosen here. 
18+ /// 
19+ /// This should only contain a `None` if the supervisor has not (yet) been initialised; 
20+ /// otherwise, if `init_sv` was called and did not error, this will always be nonempty. 
1821static  SUPERVISOR :  std:: sync:: Mutex < Option < Supervisor > >  = std:: sync:: Mutex :: new ( None ) ; 
1922
2023/// The main means of communication between the child and parent process, 
@@ -55,21 +58,14 @@ impl Supervisor {
5558/// 
5659/// SAFETY: The resulting guard must be dropped *via `end_ffi`* immediately 
5760/// after the desired call has concluded. 
58- pub  unsafe  fn  start_ffi ( 
59-         alloc :  & Rc < RefCell < IsolatedAlloc > > , 
60-     )  -> SvFfiGuard < ' _ > 
61-     { 
61+ pub  unsafe  fn  start_ffi ( alloc :  & Rc < RefCell < IsolatedAlloc > > )  -> SvFfiGuard < ' _ >  { 
6262        let  mut  sv_guard = SUPERVISOR . lock ( ) . unwrap ( ) ; 
6363        // If the supervisor is not initialised for whatever reason, fast-return. 
6464        // This might be desired behaviour, as even on platforms where ptracing 
6565        // is not implemented it enables us to enforce that only one FFI call 
6666        // happens at a time. 
6767        let  Some ( sv)  = sv_guard. as_mut ( )  else  { 
68-             return  SvFfiGuard  { 
69-                 alloc, 
70-                 sv_guard, 
71-                 cb_stack :  None , 
72-             } ; 
68+             return  SvFfiGuard  {  alloc,  sv_guard,  cb_stack :  None  } ; 
7369        } ; 
7470
7571        // Get pointers to all the pages the supervisor must allow accesses in 
@@ -101,11 +97,7 @@ impl Supervisor {
10197        // modifications to our memory - simply waiting on the recv() doesn't 
10298        // count. 
10399        signal:: raise ( signal:: SIGSTOP ) . unwrap ( ) ; 
104-         SvFfiGuard  { 
105-             alloc, 
106-             sv_guard, 
107-             cb_stack :  Some ( raw_stack_ptr) , 
108-         } 
100+         SvFfiGuard  {  alloc,  sv_guard,  cb_stack :  Some ( raw_stack_ptr)  } 
109101    } 
110102
111103    /// Undoes FFI-related preparations, allowing Miri to continue as normal, then 
@@ -116,9 +108,7 @@ impl Supervisor {
116108/// SAFETY: The `sv_guard` and `raw_stack_ptr` passed must be the same ones 
117109/// received by a prior call to `start_ffi`, and the allocator must be the 
118110/// one passed to it also. 
119- pub  unsafe  fn  end_ffi ( 
120-         guard :  SvFfiGuard < ' _ > , 
121-     )  -> Option < MemEvents >  { 
111+ pub  unsafe  fn  end_ffi ( guard :  SvFfiGuard < ' _ > )  -> Option < MemEvents >  { 
122112        let  alloc = guard. alloc ; 
123113        let  mut  sv_guard = guard. sv_guard ; 
124114        let  cb_stack = guard. cb_stack ; 
@@ -162,10 +152,6 @@ impl Supervisor {
162152/// supervisor process could not be created successfully; else, the caller 
163153/// is now the child process and can communicate via `start_ffi`/`end_ffi`, 
164154/// receiving back events through `get_events`. 
165- ///  
166- /// When forking to initialise the supervisor, the child raises a `SIGSTOP`; if 
167- /// the parent successfully ptraces the child, it will allow it to resume. Else, 
168- /// the child will be killed by the parent. 
169155/// 
170156/// # Safety 
171157/// The invariants for `fork()` must be upheld by the caller, namely either: 
0 commit comments