shadow / shadow

Shadow is a discrete-event network simulator that directly executes real application code, enabling you to simulate distributed systems with thousands of network-connected processes in realistic and scalable private network experiments using your laptop, desktop, or server running Linux.
https://shadow.github.io
Other
1.42k stars 238 forks source link

Shim sendfile to EINVAL #3366

Open datacompboy opened 3 weeks ago

datacompboy commented 3 weeks ago

Describe the issue Java's transferTo tries to use sendfile and fallback to read/send in case of EINVAL

To Reproduce Try to run Kafka under Shadow

Shadow (please complete the following information):

Additional context Just adding EINVAL shim to src/main/host/syscall/handler/mod.rs:

+            SyscallNum::NR_sendfile => {
+                log::trace!("Return EINVAL for sendfile {} ({})", syscall_name, ctx.args.number);
+
+                let rv = Err(Errno::EINVAL.into());
+
+                log_syscall_simple(
+                    ctx.objs.process,
+                    ctx.objs.process.strace_logging_options(),
+                    ctx.objs.thread.id(),
+                    syscall_name,
+                    "...",
+                    &rv,
+                )
+                .unwrap();
+
+                rv
+            }

Makes java fallback to read+recv.

sporksmith commented 3 weeks ago

Also touched on in this issue about some other IO syscalls used by Java golang: https://github.com/shadow/shadow/issues/3322

Also this broader issue about policies/features around these sort of "stub" implementations: https://github.com/shadow/shadow/issues/3280

Offhand, I think this particular syscall would be fairly easy to implement for real.

sporksmith commented 3 weeks ago

Offhand, I think this particular syscall would be fairly easy to implement for real.

Ah, actually #3322 talks about this; we probably need a little bit of refactoring to handle these sort of syscalls.