Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 520 [details]
Sample code to reproduce
Process.MainModule.FileName is inconsistent, depending on how the application is executed.
If the exe is in the current directory, the output is the path to the exe:
user@ubuntu:~/Projects/test/test/bin/Debug$ /opt/mono-2.10.6/bin/mono ./test.exe
If the exe is not in the current directory, the output is the path to mono itself:
user@ubuntu:~/Projects/test/test/bin$ /opt/mono-2.10.6/bin/mono ./Debug/test.exe
Note that the response from Assembly.GetEntryAssembly().Location is always correct.
This has been tested on ubuntu and CentOS, with the same results.
public static void Main (string args)
Console.WriteLine("FileName: " + fileName);
Console.WriteLine("FileName2: " + fileName2);
The problem is in get_module_name () in processes.c, where process_handle->proc_name is the relative file name, while found_module->filename is the absolute filename, so the two don't match, falling back to:
if (procname_ext == NULL)
/* If it's *still* null, we might have hit the
* case where reading /proc/$pid/maps gives an
* empty file for this user.
procname_ext = get_process_name_from_proc (pid);
I have a suggested fix, but i can't guarantee it will be accepted
Description and diff in the above pull request.
I am OK if the fix gets rejected though, it is just one possible fix which works for this patch. It seems to be safe in light of similar code in the same function, as described in the pull request/commit.
Ooops-- typo: "which works for this patch" should read "which works for this sample code".
I merged this patch.