-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WASM] Anonymous pipes issue #75394
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsIn dotnet/BenchmarkDotNet#2092 I wanted to use Anonymous Pipes for communication between Host and Benchmark process. The idea was very simple. The host process (always a .NET console app) creates two anonymous pipes: using AnonymousPipeServerStream inputFromBenchmark = new AnonymousPipeServerStream(PipeDirection.In, HandleInheritability.Inheritable);
using AnonymousPipeServerStream acknowledgments = new AnonymousPipeServerStream(PipeDirection.Out, HandleInheritability.Inheritable); Starts a new process and provides the handles as strings: string args = benchmarkId.ToArguments(inputFromBenchmark.GetClientHandleAsString(), acknowledgments.GetClientHandleAsString()); Then the benchmark process parses the ids, creates a private Stream OpenAnonymousPipe(string fileHandle, FileAccess access)
{
var sfh = new SafeFileHandle(new IntPtr(int.Parse(fileHandle)), ownsHandle: true);
return new FileStream(sfh, access);
} It works fine for .NET, .NET Framework on all OSes but not with WASM. On Linux, I am getting following error when trying to perform first read/write:
BenchmarkDotNet is using v8 to run the benchmarks ( @radical @lambdageek @naricc @vargaz Have you ever faced similar issue with WASM or have any idea what could be going wrong? Can v8 be internally staring another process with no handle inheritance for some kind of sandboxing? I would really like to get it working and avoid having dedicated code path for WASM.
|
v8/emscripten in general doesn't support communicating with the host machine except console output. So emitting structured output to the console and parsing it is a possible way to make (one way) communication work. |
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsIn dotnet/BenchmarkDotNet#2092 I wanted to use Anonymous Pipes for communication between Host and Benchmark process. The idea was very simple. The host process (always a .NET console app) creates two anonymous pipes: using AnonymousPipeServerStream inputFromBenchmark = new AnonymousPipeServerStream(PipeDirection.In, HandleInheritability.Inheritable);
using AnonymousPipeServerStream acknowledgments = new AnonymousPipeServerStream(PipeDirection.Out, HandleInheritability.Inheritable); Starts a new process and provides the handles as strings: string args = benchmarkId.ToArguments(inputFromBenchmark.GetClientHandleAsString(), acknowledgments.GetClientHandleAsString()); Then the benchmark process parses the ids, creates a private Stream OpenAnonymousPipe(string fileHandle, FileAccess access)
{
var sfh = new SafeFileHandle(new IntPtr(int.Parse(fileHandle)), ownsHandle: true);
return new FileStream(sfh, access);
} It works fine for .NET, .NET Framework on all OSes but not with WASM. On Linux, I am getting following error when trying to perform first read/write:
BenchmarkDotNet is using v8 to run the benchmarks ( @radical @lambdageek @naricc @vargaz Have you ever faced similar issue with WASM or have any idea what could be going wrong? Can v8 be internally staring another process with no handle inheritance for some kind of sandboxing? I would really like to get it working and avoid having dedicated code path for WASM.
|
@vargaz thanks! |
@radical has done this in the context of the wasm app host he may have some suggestions about a robust approach |
In dotnet/BenchmarkDotNet#2092 I wanted to use Anonymous Pipes for communication between Host and Benchmark process.
The idea was very simple. The host process (always a .NET console app) creates two anonymous pipes:
Starts a new process and provides the handles as strings:
Then the benchmark process parses the ids, creates a
SafeFileHandle
from it and provides it toFileStream
that is later used for reading/writing:It works fine for .NET, .NET Framework on all OSes but not with WASM.
On Linux, I am getting following error when trying to perform first read/write:
BenchmarkDotNet is using v8 to run the benchmarks (
v8 --expose_wasm test-main.js
).@radical @lambdageek @naricc @vargaz Have you ever faced similar issue with WASM or have any idea what could be going wrong?
Can v8 be internally staring another process with no handle inheritance for some kind of sandboxing?
Can Emscripten not support anonymous pipes by design (security?)?
I would really like to get it working and avoid having dedicated code path for WASM.
The text was updated successfully, but these errors were encountered: