Hardcode injection lib path.
authorMikhail Kurinnoi <m.kurinnoi@samsung.com>
Mon, 3 Jun 2019 12:18:47 +0000 (15:18 +0300)
committerAlexander Soldatov/AI Compiler Lab /SRR/Staff Engineer/삼성전자 <soldatov.a@samsung.com>
Thu, 6 Jun 2019 16:03:37 +0000 (19:03 +0300)
Fix https://github.sec.samsung.net/dotnet/dotnet-launcher/issues/59

NativeLauncher/dotnet.debugger
NativeLauncher/launcher/dotnet/dotnet_launcher.cc
NativeLauncher/launcher/injection.cc
README.md

index fea3b4a..22338b2 100644 (file)
@@ -32,7 +32,6 @@ DEFAULT_OPT /home/owner/share/tmp/sdk_tools/heaptrack/heaptrack_interpret
 DEFAULT_OPT -o
 DEFAULT_OPT /home/owner/share/tmp/sdk_tools/profctl/profctl_heaptrack.log
 DEFAULT_OPT -E
-DEFAULT_OPT    DOTNET_LAUNCHER_INJECT=/home/owner/share/tmp/sdk_tools/heaptrack/libheaptrack_inject.so
 DEFAULT_OPT    DUMP_HEAPTRACK_OUTPUT=/home/owner/share/tmp/sdk_tools/heaptrack/heaptrack_fifo
 DEFAULT_OPT    CORECLR_PROFILER={C7BAD323-25F0-4C0B-B354-566390B215CA}
 DEFAULT_OPT    CORECLR_PROFILER_PATH=/home/owner/share/tmp/sdk_tools/heaptrack/libprofiler.so
index b76f54a..48252e8 100644 (file)
@@ -291,8 +291,7 @@ CoreRuntime::~CoreRuntime()
 
 int CoreRuntime::initialize(bool standalone)
 {
-       // checkInjection checks dotnet-launcher run mode,
-       // if it contains DOTNET_LAUNCHER_INJECT variable, it injects library.
+       // checkInjection checks dotnet-launcher run mode
        // At the moment, this mechanism is used only when the Memory Profiler is started.
        int res = checkInjection();
        if (res != 0) {
index 3efd3a9..819af59 100644 (file)
 
 #include <dlfcn.h>
 
+#define HT_PATH "/home/owner/share/tmp/sdk_tools/heaptrack/"
+#define HT_LIB_PATH HT_PATH "libprofiler.so"
+#define HT_INJECTION_LIB_PATH HT_PATH "libheaptrack_inject.so"
+
 static int injectLibrary(const char path[])
 {
        typedef int inject_func();
@@ -51,42 +55,25 @@ static int injectLibrary(const char path[])
 
 int checkInjection()
 {
-       int res = -1;
        char *env = nullptr;
-       char* injectableLibs = nullptr;
-       const char *delim = ", ";
-       char *lib = nullptr;
-       char *saveptr = nullptr;
 
-       env = getenv("DOTNET_LAUNCHER_INJECT");
+       env = getenv("CORECLR_PROFILER_PATH");
        if (env == nullptr) {
-               res = 0;
-               return res;
+               return 0;
        }
 
-       _INFO("##### Perform injection #########");
-
-       injectableLibs = strdup(env);
-       if (injectableLibs == nullptr) {
-               _ERR("Fail to allocate memory for injectable library paths\n");
-               return res;
+       // At the moment, this mechanism is used only when the Memory Profiler is started.
+       if (strcmp(env, HT_LIB_PATH) != 0) {
+               return 0;
        }
 
-       res = 0;
-       lib = strtok_r(injectableLibs, delim, &saveptr);
-       for(; lib != nullptr; lib = strtok_r(nullptr, delim, &saveptr)) {
-               if (injectLibrary(lib) != 0) {
-                       res = -1;
-                       break;
-               }
-       }
+       _INFO("##### Perform injection #########");
 
-       if (res == 0) {
-               _INFO("##### Injection finished #########");
-       } else {
+       if (injectLibrary(HT_INJECTION_LIB_PATH) != 0) {
                _INFO("##### Injection failed #########");
+               return -1;
        }
 
-       free(injectableLibs);
-       return res;
+       _INFO("##### Injection finished #########");
+       return 0;
 }
index 1ac01f9..e85863e 100644 (file)
--- a/README.md
+++ b/README.md
@@ -14,14 +14,6 @@ dotnet-launcher [options...] [args...]
 * --standalone [assembly path]  
    Run assembly with the current user environment.
 
-#### environment
-
-* DOTNET_LAUNCHER_INJECT  
-   A list of additional libraries to be loaded with `dlopen()` and call to
-   `int dotnet_launcher_inject()` initialization hook. If hook returns non-zero
-   status initialization will be failed. The items of the list can be separated
-   by spaces or colons, and there is no support for escaping either separator.
-
 ----
 
 ### Anatomy