Storage API which is used to get SpecialFolder(Music, Picture, Video) makes threads internally,
and it makes crash when we call setenv() function in the launcher because setenv() is not thread-safe function.
So, use setEnvironmentVariable() function which set envrionment variable in the .NET runtime.
error = storage_get_directory(__storageId, type, &path);
if (error == STORAGE_ERROR_NONE && path != NULL) {
error = storage_get_directory(__storageId, type, &path);
if (error == STORAGE_ERROR_NONE && path != NULL) {
- setenv(key, const_cast<char *>(path), 1);
+ if (setEnvironmentVariable) {
+ setEnvironmentVariable(key, const_cast<char *>(path));
+ } else {
+ _ERR("coreclr is not initialized!. setEnvironmentVariable() function is not ready!");
+ _exit(0);
+ }
_INFO("libcoreclr dlopen and dlsym success");
_INFO("libcoreclr dlopen and dlsym success");
- // Set environment for System.Environment.SpecialFolder
- // Below function creates dbus connection by callging storage API.
- // If dbus connection is created bofere fork(), forked process cannot use dbus.
- // To avoid gdbus blocking issue, below function should be called after fork()
- initEnvForSpecialFolder();
-
std::string tpa;
char* pluginTPA = pluginGetTPA();
if (pluginTPA && pluginTPA[0] != '\0') {
std::string tpa;
char* pluginTPA = pluginGetTPA();
if (pluginTPA && pluginTPA[0] != '\0') {
+
+ // Set environment for System.Environment.SpecialFolder
+ // Below function creates dbus connection by callging storage API.
+ // If dbus connection is created bofere fork(), forked process cannot use dbus.
+ // To avoid gdbus blocking issue, below function should be called after fork()
+ // Addtionally, setenv() is not thread-safe function. storage API makes thread internally
+ // and it makes crash while calling setenv(). So, use setEnvrionmentVariable() instead of setenv()
+ initEnvForSpecialFolder();
+
__initialized = true;
_INFO("CoreRuntime initialize success");
__initialized = true;
_INFO("CoreRuntime initialize success");