Bug 1089 Fix: Fix proc/mod name match by also starting at last / in procname
authorRob Wilkens <RobWilkens@gmail.com>
Mon, 25 Jun 2012 14:49:39 +0000 (10:49 -0400)
committerRob Wilkens <RobWilkens@gmail.com>
Mon, 25 Jun 2012 14:49:39 +0000 (10:49 -0400)
commit82efcac4c81b8e95422d6b180c2ddbdadb4f8c8a
tree1bacec1700f7d80c9618b24efc8bd7f1f709a201
parentc7c0c5a50acef682b113f0c28e44b30646bb6cb0
Bug 1089 Fix: Fix proc/mod name match by also starting at last / in procname

Per Bug 1089, found we were failing to match process name to module name
when we were running a process via a subdirectory.

We were already stripping the path off the module name in the following
lines:

                lastsep = strrchr (mname, '/');
                if (lastsep)
                        if (!strcmp (lastsep+1, pname))
                                result = TRUE;

But we never did a similar strip of the module (pname) file path.  My
presumption is that if it's safe to strip the path off the process name, it
should be equally safe to strip the path off the module name.

This works for the sample code in bug 1089:
https://bugzilla.xamarin.com/show_bug.cgi?id=1089

I am not sure it's smart to strip the path off either process name or module
name, but if you do it from one, it should be safe to do it from the other.

Feel free to reject this patch if you do not like this change.  This is my
first time modifying C code in mono, and i feel a little uneasy doing it.

I will be straightforward and honest here, I did some debugging, and
the process name was resolving as follows when run as a subdirectory:

pname=[/home/robwilkens/test10.exe]

The actual path should have been (when run as : "mono monotests/test10.exe")

/home/robwilkens/monotests/test10.exe

The monotests part of the directory was never included in pname.

So the relative path was lost somewhere along the way.
mono/io-layer/processes.c