question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.IO.IOException: Write fault on path /[Unknown]

See original GitHub issue

In the case of providing an invalid option to a cmd-line tool, I would except to receive the cmd’s exit code of 1 (in this case, running ffmpeg via Xamarin.Android), instead an IOException thrown.

FYI: When ffmpeg is provided the correct option(s) and/or a media file that it can transcode, MedallionShell works great on Xamarin.Android (thanks 😀 )

Example code:

var cmd = Command.Run(ffmpegPath, (new string[]
{
"-hide_banner",
"-some_invalid_option",
}), ((options) =>
{
	options.WorkingDirectory(workingDir);
}));
var tasks = new List<Task>
{
	cmd.Task,
	cmd.StandardOutput.PipeToAsync(stdOutCollection),
	cmd.StandardError.PipeToAsync(stdErrCollection)
};
Task.WaitAll(tasks.ToArray());
exitCode = cmd.Result.ExitCode;

Note: stdOutCollection/stdErrCollection are ObservableCollections

Exception/Stacktrace:

[MonoDroid] System.IO.IOException: Write fault on path /[Unknown]
[MonoDroid]   at System.IO.FileStream.WriteInternal (System.Byte[] src, System.Int32 offset, System.Int32 count) [0x00077] in <fa70666c4440451cb5ca34569f933bb4>:0 
[MonoDroid]   at System.IO.FileStream.Write (System.Byte[] array, System.Int32 offset, System.Int32 count) [0x00090] in <fa70666c4440451cb5ca34569f933bb4>:0 
[MonoDroid]   at System.IO.StreamWriter.Flush (System.Boolean flushStream, System.Boolean flushEncoder) [0x00042] in <fa70666c4440451cb5ca34569f933bb4>:0 
[MonoDroid]   at System.IO.StreamWriter.set_AutoFlush (System.Boolean value) [0x00010] in <fa70666c4440451cb5ca34569f933bb4>:0 
[MonoDroid]   at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x00353] in <5a97d41d36694fb19855c17429527b10>:0 
[MonoDroid]   at System.Diagnostics.Process.Start () [0x0003a] in <5a97d41d36694fb19855c17429527b10>:0 
[MonoDroid]   at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
[MonoDroid]   at Medallion.Shell.ProcessCommand..ctor (System.Diagnostics.ProcessStartInfo startInfo, System.Boolean throwOnError, System.Boolean disposeOnExit, System.TimeSpan timeout, System.Threading.CancellationToken cancellationToken, System.Text.Encoding standardInputEncoding) [0x0004a] in <dcb0641c39fd4991a9750bcbbb6f72ce>:0 
[MonoDroid]   at Medallion.Shell.Shell.Run (System.String executable, System.Collections.Generic.IEnumerable`1[T] arguments, System.Action`1[T] options) [0x000f6] in <dcb0641c39fd4991a9750bcbbb6f72ce>:0 
[MonoDroid]   at Medallion.Shell.Command.Run (System.String executable, System.Collections.Generic.IEnumerable`1[T] arguments, System.Action`1[T] options) [0x00005] in <dcb0641c39fd4991a9750bcbbb6f72ce>:0 
[MonoDroid]   at GifVideo.MainActivity+<>c__DisplayClass2_0.<OnCreate>b__4 () [0x00088] in /Volumes/Code/code/Projects/GifVideo/GifVideo/MainActivity.cs:72 
[MonoDroid]   at System.Threading.Tasks.Task.InnerInvoke () [0x0000f] in <fa70666c4440451cb5ca34569f933bb4>:0 
[MonoDroid]   at System.Threading.Tasks.Task.Execute () [0x00010] in <fa70666c4440451cb5ca34569f933bb4>:0 
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <fa70666c4440451cb5ca34569f933bb4>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <fa70666c4440451cb5ca34569f933bb4>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <fa70666c4440451cb5ca34569f933bb4>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <fa70666c4440451cb5ca34569f933bb4>:0 
[MonoDroid]   at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <fa70666c4440451cb5ca34569f933bb4>:0 
[MonoDroid]   at GifVideo.MainActivity+<>c__DisplayClass2_0+<<OnCreate>b__2>d.MoveNext () [0x00048] in /Volumes/Code/code/Projects/GifVideo/GifVideo/MainActivity.cs:47 
[MonoDroid] --- End of stack trace from previous location where exception was thrown ---
[MonoDroid]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <fa70666c4440451cb5ca34569f933bb4>:0 
[MonoDroid]   at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in <fa70666c4440451cb5ca34569f933bb4>:0 
[MonoDroid]   at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <f7bb669be1a3453caf7f53a12b803ea2>:0 
[MonoDroid]   at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <f7bb669be1a3453caf7f53a12b803ea2>:0 
[MonoDroid]   at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <f7bb669be1a3453caf7f53a12b803ea2>:0 
[MonoDroid]   at (wrapper dynamic-method) System.Object.c7921d6c-67df-4e70-810d-9325c40be88e(intptr,intptr)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
madelsoncommented, Apr 26, 2018

Hi @sushihangover thanks for reporting this.

There is a mechanism in place that is supposed to guard against this, but right now it is only enabled on Mono. We detect Mono by doing:

Type.GetType("Mono.Runtime") != null

What do you get when running this check on Xamarin/Android? What version of Mono are you running?

EDIT

Looking more closely at the stack trace, it seems like this is actually failing inside Process.Start. This feels like a runtime bug to me, since it will leave the Process object in an inconsistent state with only some of the streams set up.

That said, I’m not against having MedallionShell work around this, since one of the library’s main goals is working around oddities in the Process API.

EDIT

I’ve tried to reproduce this using ffmpeg and Mono on Windows but I don’t see the error. Could be an OS difference around how processes start. Windows process start isn’t the fastest so maybe it just gets lucky and avoids this race condition.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't write input to process C# Mono
Unhandled Exception: System.IO.IOException: Write fault on path /Workspace/export/misc/[Unknown] at System.IO.FileStream.
Read more >
System.IO.IOException: Write fault on path [Unknown]
Nuget packages fails when compiling on Linux with Mono and msbuild (Mono is latest one 6.12). https://www.nuget.org/packages/ ...
Read more >
Why am I getting this error on a new Xamarin Forms ...
IO.DirectoryNotFoundException: Could not find a part of the path 'AccessibilityManagerCompat_AccessibilityStateChangeListenerImplementor.class'.
Read more >
Couldn't write save file! We got an exception: System.IO. ...
IO.File.WriteAllBytes (System.String path, System. ... MoveNext () [0x00000] in <filename unknown>:0 Error when saving to disk: System.IO.
Read more >
IOException: Sharing violation on path...
I have 3 buttons, when one of them is clicked, it saves the text value of the button to a .dat file, however,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found