summaryrefslogtreecommitdiff
path: root/src/coreclr
diff options
context:
space:
mode:
authorJim Ma <mazong1123@gmail.com>2017-04-25 17:40:36 +1200
committerGaurav Khanna <gkhanna@microsoft.com>2017-04-24 22:40:36 -0700
commit9e3ef8eb56d5027ed96348e89911afacbccee9f0 (patch)
treec00841e407e144b9e934dffba9407eb8be8bdca9 /src/coreclr
parentc53fa592ba54c0f346856d680cc30348850eba83 (diff)
downloadcoreclr-9e3ef8eb56d5027ed96348e89911afacbccee9f0.tar.gz
coreclr-9e3ef8eb56d5027ed96348e89911afacbccee9f0.tar.bz2
coreclr-9e3ef8eb56d5027ed96348e89911afacbccee9f0.zip
Ensure using the given executable path. (#10525)
* Ensure using the given executable path. Fix the bug that corerun trying to load the executable from current directory even if the user has specified a full path of the executable. Fix #5631 * Revert "Ensure using the given executable path." This reverts commit d237e6329f85132429176a0644cf6d93c9437ff4. * Partially implemented. * Ensure app context using correct IL file path. Extracting simple name from the given file path and look up its value in tpa list. If the value does not equal to the given file path, we update the value with correct given file path. Fix #5631 * Re-arrange the slashIndex to eliminate unneccessary code. * A few performance improvement with a memory leak bug fixed. * Added the absolute path of target assembly to tpa list. Fix #5631 * Added the path of target assembly to tpa on Windows. Fix #5631
Diffstat (limited to 'src/coreclr')
-rw-r--r--src/coreclr/hosts/corerun/corerun.cpp14
-rw-r--r--src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp10
2 files changed, 23 insertions, 1 deletions
diff --git a/src/coreclr/hosts/corerun/corerun.cpp b/src/coreclr/hosts/corerun/corerun.cpp
index c65c626615..a9e3b66f3b 100644
--- a/src/coreclr/hosts/corerun/corerun.cpp
+++ b/src/coreclr/hosts/corerun/corerun.cpp
@@ -470,6 +470,18 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo
return false;
}
+ StackSString tpaList;
+ if (!managedAssemblyFullName.IsEmpty())
+ {
+ // Target assembly should be added to the tpa list. Otherwise corerun.exe
+ // may find wrong assembly to execute.
+ // Details can be found at https://github.com/dotnet/coreclr/issues/5631
+ tpaList = managedAssemblyFullName;
+ tpaList.Append(W(';'));
+ }
+
+ tpaList.Append(hostEnvironment.GetTpaList());
+
//-------------------------------------------------------------
// Create an AppDomain
@@ -499,7 +511,7 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo
};
const wchar_t *property_values[] = {
// TRUSTED_PLATFORM_ASSEMBLIES
- hostEnvironment.GetTpaList(),
+ tpaList,
// APP_PATHS
appPath,
// APP_NI_PATHS
diff --git a/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp b/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp
index df4c93f427..f97f262993 100644
--- a/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp
+++ b/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp
@@ -314,6 +314,15 @@ int ExecuteManagedAssembly(
GetDirectory(managedAssemblyAbsolutePath, appPath);
std::string tpaList;
+ if (strlen(managedAssemblyAbsolutePath) > 0)
+ {
+ // Target assembly should be added to the tpa list. Otherwise corerun.exe
+ // may find wrong assembly to execute.
+ // Details can be found at https://github.com/dotnet/coreclr/issues/5631
+ tpaList = managedAssemblyAbsolutePath;
+ tpaList.append(":");
+ }
+
// Construct native search directory paths
std::string nativeDllSearchDirs(appPath);
char *coreLibraries = getenv("CORE_LIBRARIES");
@@ -326,6 +335,7 @@ int ExecuteManagedAssembly(
AddFilesFromDirectoryToTpaList(coreLibraries, tpaList);
}
}
+
nativeDllSearchDirs.append(":");
nativeDllSearchDirs.append(clrFilesAbsolutePath);