_INFO("Inject %s library", path);
- // FIXME: remove RTLD_GLOBAL?
+ // Current implementation of heaptrack CLR profiler requires RTLD_GLOBAL
lib = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
if (lib == nullptr) {
_ERR("%s", dlerror());
- goto ret;
+ return res;
}
inject = reinterpret_cast<inject_func*>(dlsym(lib, inject_sym));
if (inject == nullptr) {
_ERR("%s is not found in the %s", inject_sym, path);
- goto ret;
+ return res;
}
res = inject();
-
-ret:
return res;
}
char* injectableLibs = nullptr;
const char *delim = ", ";
char *lib = nullptr;
+ char *saveptr = nullptr;
env = getenv("DOTNET_LAUNCHER_INJECT");
if (env == nullptr) {
res = 0;
- goto ret;
+ return res;
}
_INFO("##### Perform injection #########");
injectableLibs = strdup(env);
if (injectableLibs == nullptr) {
_ERR("Fail to allocate memory for injectable library paths\n");
- goto ret;
+ return res;
}
res = 0;
- lib = strtok(injectableLibs, delim);
- for(; lib != nullptr; lib = strtok(nullptr, delim)) {
+ lib = strtok_r(injectableLibs, delim, &saveptr);
+ for(; lib != nullptr; lib = strtok_r(nullptr, delim, &saveptr)) {
if (injectLibrary(lib) != 0) {
res = -1;
break;
_INFO("##### Injection failed #########");
}
-ret:
free(injectableLibs);
-
return res;
}