You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looking into the code, I see that System.Diagnostics.Process.ProcessName internally uses ves_icall_System_Diagnostics_Process_ProcessName_internal, which in its turn calls mono_w32process_module_get_name, and in some cases it uses mono_w32process_get_name:
In my case this leads to No such file or directory error when I'm trying to create the logs located here: /tmp/SomeLogsFromProcessWithName{Process.GetCurrentProcess().ProcessName}#{Process.GetCurrentProcess().Id}.log
The text was updated successfully, but these errors were encountered:
I don't see how mono_w32process_get_name could try to open /proc/self/exe,
Could you please identify what file name is actually causing No such file or directory by
using a debugger or
strace (available in almost all Linux distributions): strace --follow-forks --output=traces /usr/bin/mono test.exe
and then searching the traces file for the relevant ENOENT (No such file or directory) error.
@ThomasKuehne Hi! There are two errors, the first is that we use too short buffer when parsing maps file, and the second is that in this case we fallback to /proc/self/exe and doesn't extract an executable name from it. Here is simple repro:
Create a project with this:
using System;
using System.Diagnostics;
namespace ConsoleApplication1
{
internal class Program
{
public static void Main(string[] args)
{
Console.WriteLine(Process.GetCurrentProcess().ProcessName);
}
}
}
Build, and move to a directory with long full path (235 characters in my case)
Hi!
It turned out that sometimes
Process.GetCurrentProcess().ProcessName
can return full path to the executable in spite of the documentation: The ProcessName property holds an executable file name, such as Outlook, that does not include the .exe extension or the path. (as per https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.processname?view=netframework-4.8).Looking into the code, I see that
System.Diagnostics.Process.ProcessName
internally usesves_icall_System_Diagnostics_Process_ProcessName_internal
, which in its turn callsmono_w32process_module_get_name
, and in some cases it usesmono_w32process_get_name
:mono/mono/metadata/w32process-unix.c
Lines 1027 to 1036 in 8266c56
which is based on readlink /proc/self/exe:
mono/mono/metadata/w32process-unix-default.c
Lines 78 to 89 in 8266c56
In my case this leads to
No such file or directory
error when I'm trying to create the logs located here:/tmp/SomeLogsFromProcessWithName{Process.GetCurrentProcess().ProcessName}#{Process.GetCurrentProcess().Id}.log
The text was updated successfully, but these errors were encountered: