miri/shims/unix/
unnamed_socket.rs

1//! This implements "anonymous" sockets, that do not correspond to anything on the host system and
2//! are entirely implemented inside Miri.
3//! We also use the same infrastructure to implement unnamed pipes.
4
5use std::cell::{Cell, OnceCell, RefCell};
6use std::collections::VecDeque;
7use std::io;
8use std::io::ErrorKind;
9
10use crate::concurrency::VClock;
11use crate::shims::files::{
12    EvalContextExt as _, FileDescription, FileDescriptionRef, WeakFileDescriptionRef,
13};
14use crate::shims::unix::UnixFileDescription;
15use crate::shims::unix::linux_like::epoll::{EpollReadyEvents, EvalContextExt as _};
16use crate::*;
17
18/// The maximum capacity of the socketpair buffer in bytes.
19/// This number is arbitrary as the value can always
20/// be configured in the real system.
21const MAX_SOCKETPAIR_BUFFER_CAPACITY: usize = 212992;
22
23#[derive(Debug, PartialEq)]
24enum AnonSocketType {
25    // Either end of the socketpair fd.
26    Socketpair,
27    // Read end of the pipe.
28    PipeRead,
29    // Write end of the pipe.
30    PipeWrite,
31}
32
33/// One end of a pair of connected unnamed sockets.
34#[derive(Debug)]
35struct AnonSocket {
36    /// The buffer we are reading from, or `None` if this is the writing end of a pipe.
37    /// (In that case, the peer FD will be the reading end of that pipe.)
38    readbuf: Option<RefCell<Buffer>>,
39    /// The `AnonSocket` file descriptor that is our "peer", and that holds the buffer we are
40    /// writing to. This is a weak reference because the other side may be closed before us; all
41    /// future writes will then trigger EPIPE.
42    peer_fd: OnceCell<WeakFileDescriptionRef<AnonSocket>>,
43    /// Indicates whether the peer has lost data when the file description is closed.
44    /// This flag is set to `true` if the peer's `readbuf` is non-empty at the time
45    /// of closure.
46    peer_lost_data: Cell<bool>,
47    /// A list of thread ids blocked because the buffer was empty.
48    /// Once another thread writes some bytes, these threads will be unblocked.
49    blocked_read_tid: RefCell<Vec<ThreadId>>,
50    /// A list of thread ids blocked because the buffer was full.
51    /// Once another thread reads some bytes, these threads will be unblocked.
52    blocked_write_tid: RefCell<Vec<ThreadId>>,
53    /// Whether this fd is non-blocking or not.
54    is_nonblock: Cell<bool>,
55    // Differentiate between different AnonSocket fd types.
56    fd_type: AnonSocketType,
57}
58
59#[derive(Debug)]
60struct Buffer {
61    buf: VecDeque<u8>,
62    clock: VClock,
63}
64
65impl Buffer {
66    fn new() -> Self {
67        Buffer { buf: VecDeque::new(), clock: VClock::default() }
68    }
69}
70
71impl AnonSocket {
72    fn peer_fd(&self) -> &WeakFileDescriptionRef<AnonSocket> {
73        self.peer_fd.get().unwrap()
74    }
75}
76
77impl FileDescription for AnonSocket {
78    fn name(&self) -> &'static str {
79        match self.fd_type {
80            AnonSocketType::Socketpair => "socketpair",
81            AnonSocketType::PipeRead | AnonSocketType::PipeWrite => "pipe",
82        }
83    }
84
85    fn close<'tcx>(
86        self,
87        _communicate_allowed: bool,
88        ecx: &mut MiriInterpCx<'tcx>,
89    ) -> InterpResult<'tcx, io::Result<()>> {
90        if let Some(peer_fd) = self.peer_fd().upgrade() {
91            // If the current readbuf is non-empty when the file description is closed,
92            // notify the peer that data lost has happened in current file description.
93            if let Some(readbuf) = &self.readbuf {
94                if !readbuf.borrow().buf.is_empty() {
95                    peer_fd.peer_lost_data.set(true);
96                }
97            }
98            // Notify peer fd that close has happened, since that can unblock reads and writes.
99            ecx.check_and_update_readiness(peer_fd)?;
100        }
101        interp_ok(Ok(()))
102    }
103
104    fn read<'tcx>(
105        self: FileDescriptionRef<Self>,
106        _communicate_allowed: bool,
107        ptr: Pointer,
108        len: usize,
109        ecx: &mut MiriInterpCx<'tcx>,
110        finish: DynMachineCallback<'tcx, Result<usize, IoError>>,
111    ) -> InterpResult<'tcx> {
112        anonsocket_read(self, ptr, len, ecx, finish)
113    }
114
115    fn write<'tcx>(
116        self: FileDescriptionRef<Self>,
117        _communicate_allowed: bool,
118        ptr: Pointer,
119        len: usize,
120        ecx: &mut MiriInterpCx<'tcx>,
121        finish: DynMachineCallback<'tcx, Result<usize, IoError>>,
122    ) -> InterpResult<'tcx> {
123        anonsocket_write(self, ptr, len, ecx, finish)
124    }
125
126    fn as_unix<'tcx>(&self, _ecx: &MiriInterpCx<'tcx>) -> &dyn UnixFileDescription {
127        self
128    }
129
130    fn get_flags<'tcx>(&self, ecx: &mut MiriInterpCx<'tcx>) -> InterpResult<'tcx, Scalar> {
131        let mut flags = 0;
132
133        // Get flag for file access mode.
134        // The flag for both socketpair and pipe will remain the same even when the peer
135        // fd is closed, so we need to look at the original type of this socket, not at whether
136        // the peer socket still exists.
137        match self.fd_type {
138            AnonSocketType::Socketpair => {
139                flags |= ecx.eval_libc_i32("O_RDWR");
140            }
141            AnonSocketType::PipeRead => {
142                flags |= ecx.eval_libc_i32("O_RDONLY");
143            }
144            AnonSocketType::PipeWrite => {
145                flags |= ecx.eval_libc_i32("O_WRONLY");
146            }
147        }
148
149        // Get flag for blocking status.
150        if self.is_nonblock.get() {
151            flags |= ecx.eval_libc_i32("O_NONBLOCK");
152        }
153
154        interp_ok(Scalar::from_i32(flags))
155    }
156
157    fn set_flags<'tcx>(
158        &self,
159        mut flag: i32,
160        ecx: &mut MiriInterpCx<'tcx>,
161    ) -> InterpResult<'tcx, Scalar> {
162        // FIXME: File creation flags should be ignored.
163
164        let o_nonblock = ecx.eval_libc_i32("O_NONBLOCK");
165        let o_rdonly = ecx.eval_libc_i32("O_RDONLY");
166        let o_wronly = ecx.eval_libc_i32("O_WRONLY");
167        let o_rdwr = ecx.eval_libc_i32("O_RDWR");
168
169        // O_NONBLOCK flag can be set / unset by user.
170        if flag & o_nonblock == o_nonblock {
171            self.is_nonblock.set(true);
172            flag &= !o_nonblock;
173        } else {
174            self.is_nonblock.set(false);
175        }
176
177        // Ignore all file access mode flags.
178        flag &= !(o_rdonly | o_wronly | o_rdwr);
179
180        // Throw error if there is any unsupported flag.
181        if flag != 0 {
182            throw_unsup_format!(
183                "fcntl: only O_NONBLOCK is supported for F_SETFL on socketpairs and pipes"
184            )
185        }
186
187        interp_ok(Scalar::from_i32(0))
188    }
189}
190
191/// Write to AnonSocket based on the space available and return the written byte size.
192fn anonsocket_write<'tcx>(
193    self_ref: FileDescriptionRef<AnonSocket>,
194    ptr: Pointer,
195    len: usize,
196    ecx: &mut MiriInterpCx<'tcx>,
197    finish: DynMachineCallback<'tcx, Result<usize, IoError>>,
198) -> InterpResult<'tcx> {
199    // Always succeed on write size 0.
200    // ("If count is zero and fd refers to a file other than a regular file, the results are not specified.")
201    if len == 0 {
202        return finish.call(ecx, Ok(0));
203    }
204
205    // We are writing to our peer's readbuf.
206    let Some(peer_fd) = self_ref.peer_fd().upgrade() else {
207        // If the upgrade from Weak to Rc fails, it indicates that all read ends have been
208        // closed. It is an error to write even if there would be space.
209        return finish.call(ecx, Err(ErrorKind::BrokenPipe.into()));
210    };
211
212    let Some(writebuf) = &peer_fd.readbuf else {
213        // Writing to the read end of a pipe.
214        return finish.call(ecx, Err(IoError::LibcError("EBADF")));
215    };
216
217    // Let's see if we can write.
218    let available_space = MAX_SOCKETPAIR_BUFFER_CAPACITY.strict_sub(writebuf.borrow().buf.len());
219    if available_space == 0 {
220        if self_ref.is_nonblock.get() {
221            // Non-blocking socketpair with a full buffer.
222            return finish.call(ecx, Err(ErrorKind::WouldBlock.into()));
223        } else {
224            self_ref.blocked_write_tid.borrow_mut().push(ecx.active_thread());
225            // Blocking socketpair with a full buffer.
226            // Block the current thread; only keep a weak ref for this.
227            let weak_self_ref = FileDescriptionRef::downgrade(&self_ref);
228            ecx.block_thread(
229                BlockReason::UnnamedSocket,
230                None,
231                callback!(
232                    @capture<'tcx> {
233                        weak_self_ref: WeakFileDescriptionRef<AnonSocket>,
234                        ptr: Pointer,
235                        len: usize,
236                        finish: DynMachineCallback<'tcx, Result<usize, IoError>>,
237                    }
238                    |this, unblock: UnblockKind| {
239                        assert_eq!(unblock, UnblockKind::Ready);
240                        // If we got unblocked, then our peer successfully upgraded its weak
241                        // ref to us. That means we can also upgrade our weak ref.
242                        let self_ref = weak_self_ref.upgrade().unwrap();
243                        anonsocket_write(self_ref, ptr, len, this, finish)
244                    }
245                ),
246            );
247        }
248    } else {
249        // There is space to write!
250        let mut writebuf = writebuf.borrow_mut();
251        // Remember this clock so `read` can synchronize with us.
252        ecx.release_clock(|clock| {
253            writebuf.clock.join(clock);
254        });
255        // Do full write / partial write based on the space available.
256        let write_size = len.min(available_space);
257        let actual_write_size = ecx.write_to_host(&mut writebuf.buf, write_size, ptr)?.unwrap();
258        assert_eq!(actual_write_size, write_size);
259
260        // Need to stop accessing peer_fd so that it can be notified.
261        drop(writebuf);
262
263        // Unblock all threads that are currently blocked on peer_fd's read.
264        let waiting_threads = std::mem::take(&mut *peer_fd.blocked_read_tid.borrow_mut());
265        // FIXME: We can randomize the order of unblocking.
266        for thread_id in waiting_threads {
267            ecx.unblock_thread(thread_id, BlockReason::UnnamedSocket)?;
268        }
269        // Notification should be provided for peer fd as it became readable.
270        // The kernel does this even if the fd was already readable before, so we follow suit.
271        ecx.check_and_update_readiness(peer_fd)?;
272
273        return finish.call(ecx, Ok(write_size));
274    }
275    interp_ok(())
276}
277
278/// Read from AnonSocket and return the number of bytes read.
279fn anonsocket_read<'tcx>(
280    self_ref: FileDescriptionRef<AnonSocket>,
281    ptr: Pointer,
282    len: usize,
283    ecx: &mut MiriInterpCx<'tcx>,
284    finish: DynMachineCallback<'tcx, Result<usize, IoError>>,
285) -> InterpResult<'tcx> {
286    // Always succeed on read size 0.
287    if len == 0 {
288        return finish.call(ecx, Ok(0));
289    }
290
291    let Some(readbuf) = &self_ref.readbuf else {
292        // FIXME: This should return EBADF, but there's no nice way to do that as there's no
293        // corresponding ErrorKind variant.
294        throw_unsup_format!("reading from the write end of a pipe")
295    };
296
297    if readbuf.borrow_mut().buf.is_empty() {
298        if self_ref.peer_fd().upgrade().is_none() {
299            // Socketpair with no peer and empty buffer.
300            // 0 bytes successfully read indicates end-of-file.
301            return finish.call(ecx, Ok(0));
302        } else if self_ref.is_nonblock.get() {
303            // Non-blocking socketpair with writer and empty buffer.
304            // https://linux.die.net/man/2/read
305            // EAGAIN or EWOULDBLOCK can be returned for socket,
306            // POSIX.1-2001 allows either error to be returned for this case.
307            // Since there is no ErrorKind for EAGAIN, WouldBlock is used.
308            return finish.call(ecx, Err(ErrorKind::WouldBlock.into()));
309        } else {
310            self_ref.blocked_read_tid.borrow_mut().push(ecx.active_thread());
311            // Blocking socketpair with writer and empty buffer.
312            // Block the current thread; only keep a weak ref for this.
313            let weak_self_ref = FileDescriptionRef::downgrade(&self_ref);
314            ecx.block_thread(
315                BlockReason::UnnamedSocket,
316                None,
317                callback!(
318                    @capture<'tcx> {
319                        weak_self_ref: WeakFileDescriptionRef<AnonSocket>,
320                        ptr: Pointer,
321                        len: usize,
322                        finish: DynMachineCallback<'tcx, Result<usize, IoError>>,
323                    }
324                    |this, unblock: UnblockKind| {
325                        assert_eq!(unblock, UnblockKind::Ready);
326                        // If we got unblocked, then our peer successfully upgraded its weak
327                        // ref to us. That means we can also upgrade our weak ref.
328                        let self_ref = weak_self_ref.upgrade().unwrap();
329                        anonsocket_read(self_ref, ptr, len, this, finish)
330                    }
331                ),
332            );
333        }
334    } else {
335        // There's data to be read!
336        let mut readbuf = readbuf.borrow_mut();
337        // Synchronize with all previous writes to this buffer.
338        // FIXME: this over-synchronizes; a more precise approach would be to
339        // only sync with the writes whose data we will read.
340        ecx.acquire_clock(&readbuf.clock);
341
342        // Do full read / partial read based on the space available.
343        // Conveniently, `read` exists on `VecDeque` and has exactly the desired behavior.
344        let read_size = ecx.read_from_host(&mut readbuf.buf, len, ptr)?.unwrap();
345
346        // Need to drop before others can access the readbuf again.
347        drop(readbuf);
348
349        // A notification should be provided for the peer file description even when it can
350        // only write 1 byte. This implementation is not compliant with the actual Linux kernel
351        // implementation. For optimization reasons, the kernel will only mark the file description
352        // as "writable" when it can write more than a certain number of bytes. Since we
353        // don't know what that *certain number* is, we will provide a notification every time
354        // a read is successful. This might result in our epoll emulation providing more
355        // notifications than the real system.
356        if let Some(peer_fd) = self_ref.peer_fd().upgrade() {
357            // Unblock all threads that are currently blocked on peer_fd's write.
358            let waiting_threads = std::mem::take(&mut *peer_fd.blocked_write_tid.borrow_mut());
359            // FIXME: We can randomize the order of unblocking.
360            for thread_id in waiting_threads {
361                ecx.unblock_thread(thread_id, BlockReason::UnnamedSocket)?;
362            }
363            // Notify epoll waiters.
364            ecx.check_and_update_readiness(peer_fd)?;
365        };
366
367        return finish.call(ecx, Ok(read_size));
368    }
369    interp_ok(())
370}
371
372impl UnixFileDescription for AnonSocket {
373    fn get_epoll_ready_events<'tcx>(&self) -> InterpResult<'tcx, EpollReadyEvents> {
374        // We only check the status of EPOLLIN, EPOLLOUT, EPOLLHUP and EPOLLRDHUP flags.
375        // If other event flags need to be supported in the future, the check should be added here.
376
377        let mut epoll_ready_events = EpollReadyEvents::new();
378
379        // Check if it is readable.
380        if let Some(readbuf) = &self.readbuf {
381            if !readbuf.borrow().buf.is_empty() {
382                epoll_ready_events.epollin = true;
383            }
384        } else {
385            // Without a read buffer, reading never blocks, so we are always ready.
386            epoll_ready_events.epollin = true;
387        }
388
389        // Check if is writable.
390        if let Some(peer_fd) = self.peer_fd().upgrade() {
391            if let Some(writebuf) = &peer_fd.readbuf {
392                let data_size = writebuf.borrow().buf.len();
393                let available_space = MAX_SOCKETPAIR_BUFFER_CAPACITY.strict_sub(data_size);
394                if available_space != 0 {
395                    epoll_ready_events.epollout = true;
396                }
397            } else {
398                // Without a write buffer, writing never blocks.
399                epoll_ready_events.epollout = true;
400            }
401        } else {
402            // Peer FD has been closed. This always sets both the RDHUP and HUP flags
403            // as we do not support `shutdown` that could be used to partially close the stream.
404            epoll_ready_events.epollrdhup = true;
405            epoll_ready_events.epollhup = true;
406            // Since the peer is closed, even if no data is available reads will return EOF and
407            // writes will return EPIPE. In other words, they won't block, so we mark this as ready
408            // for read and write.
409            epoll_ready_events.epollin = true;
410            epoll_ready_events.epollout = true;
411            // If there is data lost in peer_fd, set EPOLLERR.
412            if self.peer_lost_data.get() {
413                epoll_ready_events.epollerr = true;
414            }
415        }
416        interp_ok(epoll_ready_events)
417    }
418}
419
420impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
421pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
422    /// For more information on the arguments see the socketpair manpage:
423    /// <https://linux.die.net/man/2/socketpair>
424    fn socketpair(
425        &mut self,
426        domain: &OpTy<'tcx>,
427        type_: &OpTy<'tcx>,
428        protocol: &OpTy<'tcx>,
429        sv: &OpTy<'tcx>,
430    ) -> InterpResult<'tcx, Scalar> {
431        let this = self.eval_context_mut();
432
433        let domain = this.read_scalar(domain)?.to_i32()?;
434        let mut flags = this.read_scalar(type_)?.to_i32()?;
435        let protocol = this.read_scalar(protocol)?.to_i32()?;
436        // This is really a pointer to `[i32; 2]` but we use a ptr-to-first-element representation.
437        let sv = this.deref_pointer_as(sv, this.machine.layouts.i32)?;
438
439        let mut is_sock_nonblock = false;
440
441        // Interpret the flag. Every flag we recognize is "subtracted" from `flags`, so
442        // if there is anything left at the end, that's an unsupported flag.
443        if this.tcx.sess.target.os == "linux" {
444            // SOCK_NONBLOCK only exists on Linux.
445            let sock_nonblock = this.eval_libc_i32("SOCK_NONBLOCK");
446            let sock_cloexec = this.eval_libc_i32("SOCK_CLOEXEC");
447            if flags & sock_nonblock == sock_nonblock {
448                is_sock_nonblock = true;
449                flags &= !sock_nonblock;
450            }
451            if flags & sock_cloexec == sock_cloexec {
452                flags &= !sock_cloexec;
453            }
454        }
455
456        // Fail on unsupported input.
457        // AF_UNIX and AF_LOCAL are synonyms, so we accept both in case
458        // their values differ.
459        if domain != this.eval_libc_i32("AF_UNIX") && domain != this.eval_libc_i32("AF_LOCAL") {
460            throw_unsup_format!(
461                "socketpair: domain {:#x} is unsupported, only AF_UNIX \
462                                 and AF_LOCAL are allowed",
463                domain
464            );
465        } else if flags != this.eval_libc_i32("SOCK_STREAM") {
466            throw_unsup_format!(
467                "socketpair: type {:#x} is unsupported, only SOCK_STREAM, \
468                                 SOCK_CLOEXEC and SOCK_NONBLOCK are allowed",
469                flags
470            );
471        } else if protocol != 0 {
472            throw_unsup_format!(
473                "socketpair: socket protocol {protocol} is unsupported, \
474                                 only 0 is allowed",
475            );
476        }
477
478        // Generate file descriptions.
479        let fds = &mut this.machine.fds;
480        let fd0 = fds.new_ref(AnonSocket {
481            readbuf: Some(RefCell::new(Buffer::new())),
482            peer_fd: OnceCell::new(),
483            peer_lost_data: Cell::new(false),
484            blocked_read_tid: RefCell::new(Vec::new()),
485            blocked_write_tid: RefCell::new(Vec::new()),
486            is_nonblock: Cell::new(is_sock_nonblock),
487            fd_type: AnonSocketType::Socketpair,
488        });
489        let fd1 = fds.new_ref(AnonSocket {
490            readbuf: Some(RefCell::new(Buffer::new())),
491            peer_fd: OnceCell::new(),
492            peer_lost_data: Cell::new(false),
493            blocked_read_tid: RefCell::new(Vec::new()),
494            blocked_write_tid: RefCell::new(Vec::new()),
495            is_nonblock: Cell::new(is_sock_nonblock),
496            fd_type: AnonSocketType::Socketpair,
497        });
498
499        // Make the file descriptions point to each other.
500        fd0.peer_fd.set(FileDescriptionRef::downgrade(&fd1)).unwrap();
501        fd1.peer_fd.set(FileDescriptionRef::downgrade(&fd0)).unwrap();
502
503        // Insert the file description to the fd table, generating the file descriptors.
504        let sv0 = fds.insert(fd0);
505        let sv1 = fds.insert(fd1);
506
507        // Return socketpair file descriptors to the caller.
508        let sv0 = Scalar::from_int(sv0, sv.layout.size);
509        let sv1 = Scalar::from_int(sv1, sv.layout.size);
510        this.write_scalar(sv0, &sv)?;
511        this.write_scalar(sv1, &sv.offset(sv.layout.size, sv.layout, this)?)?;
512
513        interp_ok(Scalar::from_i32(0))
514    }
515
516    fn pipe2(
517        &mut self,
518        pipefd: &OpTy<'tcx>,
519        flags: Option<&OpTy<'tcx>>,
520    ) -> InterpResult<'tcx, Scalar> {
521        let this = self.eval_context_mut();
522
523        let pipefd = this.deref_pointer_as(pipefd, this.machine.layouts.i32)?;
524        let mut flags = match flags {
525            Some(flags) => this.read_scalar(flags)?.to_i32()?,
526            None => 0,
527        };
528
529        let cloexec = this.eval_libc_i32("O_CLOEXEC");
530        let o_nonblock = this.eval_libc_i32("O_NONBLOCK");
531
532        // Interpret the flag. Every flag we recognize is "subtracted" from `flags`, so
533        // if there is anything left at the end, that's an unsupported flag.
534        let mut is_nonblock = false;
535        if flags & o_nonblock == o_nonblock {
536            is_nonblock = true;
537            flags &= !o_nonblock;
538        }
539        // As usual we ignore CLOEXEC.
540        if flags & cloexec == cloexec {
541            flags &= !cloexec;
542        }
543        if flags != 0 {
544            throw_unsup_format!("unsupported flags in `pipe2`");
545        }
546
547        // Generate file descriptions.
548        // pipefd[0] refers to the read end of the pipe.
549        let fds = &mut this.machine.fds;
550        let fd0 = fds.new_ref(AnonSocket {
551            readbuf: Some(RefCell::new(Buffer::new())),
552            peer_fd: OnceCell::new(),
553            peer_lost_data: Cell::new(false),
554            blocked_read_tid: RefCell::new(Vec::new()),
555            blocked_write_tid: RefCell::new(Vec::new()),
556            is_nonblock: Cell::new(is_nonblock),
557            fd_type: AnonSocketType::PipeRead,
558        });
559        let fd1 = fds.new_ref(AnonSocket {
560            readbuf: None,
561            peer_fd: OnceCell::new(),
562            peer_lost_data: Cell::new(false),
563            blocked_read_tid: RefCell::new(Vec::new()),
564            blocked_write_tid: RefCell::new(Vec::new()),
565            is_nonblock: Cell::new(is_nonblock),
566            fd_type: AnonSocketType::PipeWrite,
567        });
568
569        // Make the file descriptions point to each other.
570        fd0.peer_fd.set(FileDescriptionRef::downgrade(&fd1)).unwrap();
571        fd1.peer_fd.set(FileDescriptionRef::downgrade(&fd0)).unwrap();
572
573        // Insert the file description to the fd table, generating the file descriptors.
574        let pipefd0 = fds.insert(fd0);
575        let pipefd1 = fds.insert(fd1);
576
577        // Return file descriptors to the caller.
578        let pipefd0 = Scalar::from_int(pipefd0, pipefd.layout.size);
579        let pipefd1 = Scalar::from_int(pipefd1, pipefd.layout.size);
580        this.write_scalar(pipefd0, &pipefd)?;
581        this.write_scalar(pipefd1, &pipefd.offset(pipefd.layout.size, pipefd.layout, this)?)?;
582
583        interp_ok(Scalar::from_i32(0))
584    }
585}