From 5df12f517493615cd2aee051add7bb307c500d1c Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Tue, 17 Oct 2017 09:20:23 +0900 Subject: [PATCH 01/16] remove unneccessary log to remove warning message Change-Id: Icc79f0550ce69e266b00f1c95aeb029ea6579807 --- NativeLauncher/launcher/dotnet/dotnet_launcher.cc | 2 -- NativeLauncher/launcher/launcher.cc | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc index 6adff4b..682d532 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc @@ -166,8 +166,6 @@ int CoreRuntime::initialize(bool standalone) #undef CORELIB_RETURN_IF_NOSYM _DBG("libcoreclr dlopen and dlsym success"); - _DBG("this addr : %x", this); - _DBG("coreclr_initialize : %x", initializeClr); if (!standalone && pluginPreload) pluginPreload(); diff --git a/NativeLauncher/launcher/launcher.cc b/NativeLauncher/launcher/launcher.cc index 91ccb02..aaeefd6 100644 --- a/NativeLauncher/launcher/launcher.cc +++ b/NativeLauncher/launcher/launcher.cc @@ -143,7 +143,7 @@ static void preloadLibsAndWindow(bundle *extra, int type, void *userData) for (i = 0; i < len; i++) { handle = dlopen(soArray[i], RTLD_NOW); - _DBG("preload %s# - handle : %x", soArray[i], handle); + _DBG("preload %s#", soArray[i]); } // Precreate window -- 2.7.4 From 1a2aa15b1a961dcd54c46883356351e8b84bc8fb Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Thu, 2 Nov 2017 19:10:41 +0900 Subject: [PATCH 02/16] big-fix: add reference dll for NI Change-Id: Ia974ecd5469ff152204f6cf7c8adaa693b488088 (cherry picked from commit 195453317830e9b517950a6153e078f91f1e7500) --- NativeLauncher/installer-plugin/common.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NativeLauncher/installer-plugin/common.cc b/NativeLauncher/installer-plugin/common.cc index 4d5feeb..f84e79c 100644 --- a/NativeLauncher/installer-plugin/common.cc +++ b/NativeLauncher/installer-plugin/common.cc @@ -133,12 +133,12 @@ static void crossgen(const char* dllPath, const char* appPath) // get reference API directory ([DEVICE_API_DIR]/ref) int len = strlen(__DEVICE_API_DIR); - char* refAPIDir = (char*)calloc(len + 4, 1); + char* refAPIDir = (char*)calloc(len + 5, 1); if (!refAPIDir) { printf("fail to allocate memory for reference API directory\n"); return; } - snprintf(refAPIDir, len + 4, "%s%s", __DEVICE_API_DIR, "/ref"); + snprintf(refAPIDir, len + 5, "%s%s", __DEVICE_API_DIR, "/ref"); tpaDir.push_back(refAPIDir); std::string tpa; -- 2.7.4 From 2257c6b542c3bbf76619f60093fb9ee78631735f Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Wed, 23 Aug 2017 11:33:23 +0900 Subject: [PATCH 03/16] comment out unused code and change log Change-Id: I944f7ad3320bd5a15d20332ba1934fc60b162a42 --- NativeLauncher/installer-plugin/common.cc | 1 - NativeLauncher/launcher/main.cc | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/NativeLauncher/installer-plugin/common.cc b/NativeLauncher/installer-plugin/common.cc index f84e79c..f7fc71b 100644 --- a/NativeLauncher/installer-plugin/common.cc +++ b/NativeLauncher/installer-plugin/common.cc @@ -63,7 +63,6 @@ static const char* __JIT_PATH = __STR(RUNTIME_DIR)"/libclrjit.so"; #undef __STR #undef __XSTR - #if 0 static std::string replace(std::string &str, const std::string& from, const std::string& to) { diff --git a/NativeLauncher/launcher/main.cc b/NativeLauncher/launcher/main.cc index a3ad62b..0922908 100644 --- a/NativeLauncher/launcher/main.cc +++ b/NativeLauncher/launcher/main.cc @@ -51,7 +51,7 @@ int main(int argc, char *argv[]) std::vector vargs; // start index 1 to avoid passing executable name "dotnet-launcher" as a parameter - for (i = 1; i launch(appId, appRoot.c_str(), standalonePath, argsLen, args)) { _ERR("Failed to launch"); - return 0; + return 1; } } else { Launchpad.onCreate = [&runtime]() { @@ -118,7 +118,7 @@ int main(int argc, char *argv[]) }; Launchpad.onTerminate = [&runtime](const AppInfo& appInfo, int argc, char** argv) { - _DBG("terminated with app path : %s", appInfo.path.c_str()); + _DBG("launch request with app path : %s", appInfo.path.c_str()); _DBG("appId : %s", appInfo.id.c_str()); _DBG("pkg : %s", appInfo.pkg.c_str()); _DBG("type : %s", appInfo.type.c_str()); -- 2.7.4 From 14af36a2752af7008cb985f6e60e700e25b8282c Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Wed, 23 Aug 2017 15:24:40 +0900 Subject: [PATCH 04/16] check return value of loaderMain to avoid crash Change-Id: Ib5a740a34c7f8b171fb890dc1f97c51e93ad647d --- NativeLauncher/launcher/launcher.cc | 7 ++++--- NativeLauncher/launcher/launcher.h | 2 +- NativeLauncher/launcher/main.cc | 6 +++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/NativeLauncher/launcher/launcher.cc b/NativeLauncher/launcher/launcher.cc index aaeefd6..91c24a1 100644 --- a/NativeLauncher/launcher/launcher.cc +++ b/NativeLauncher/launcher/launcher.cc @@ -53,7 +53,7 @@ class LaunchpadAdapterImpl : public LaunchpadAdapter launcher(nullptr), __isLaunched(false) { } - void loaderMain(int argc, char* argv[]) override; + int loaderMain(int argc, char* argv[]) override; std::map handlers; @@ -161,7 +161,7 @@ static void preloadLibsAndWindow(bundle *extra, int type, void *userData) elm_win_precreated_object_set(__win); } -void LaunchpadAdapterImpl::loaderMain(int argc, char* argv[]) +int LaunchpadAdapterImpl::loaderMain(int argc, char* argv[]) { __argc = argc; __argv = argv; @@ -189,7 +189,6 @@ void LaunchpadAdapterImpl::loaderMain(int argc, char* argv[]) return 0; }; callbacks.terminate = [](int argc, char **argv, void* userData) -> int { - _DBG("Terminate!!"); WITH_SELF(userData) { if (self->onTerminate != nullptr) self->onTerminate(self->appInfo, argc, argv); @@ -210,6 +209,8 @@ void LaunchpadAdapterImpl::loaderMain(int argc, char* argv[]) _DBG("launchpad_loader_main is start"); int r = launchpad_loader_main(argc, argv, &(this->callbacks), &(this->adapter), this); _DBG("launchpad_loader_main is finished with [%d]", r); + + return r; } #undef WITH_SELF diff --git a/NativeLauncher/launcher/launcher.h b/NativeLauncher/launcher/launcher.h index 41ed2ac..ce91241 100644 --- a/NativeLauncher/launcher/launcher.h +++ b/NativeLauncher/launcher/launcher.h @@ -43,7 +43,7 @@ struct AppInfo { class LaunchpadAdapter { public: - virtual void loaderMain(int argc, char* argv[]) = 0; + virtual int loaderMain(int argc, char* argv[]) = 0; std::function onCreate = nullptr; std::function onLaunch = nullptr; std::function onTerminate = nullptr; diff --git a/NativeLauncher/launcher/main.cc b/NativeLauncher/launcher/main.cc index 0922908..6fcfb9b 100644 --- a/NativeLauncher/launcher/main.cc +++ b/NativeLauncher/launcher/main.cc @@ -129,7 +129,11 @@ int main(int argc, char *argv[]) if (runtime->launch(appInfo.id.c_str(), appInfo.root.c_str(), appInfo.path.c_str(), argc-1, argv+1)) _ERR("Failed to launch"); }; - Launchpad.loaderMain(argc, argv); + int ret = Launchpad.loaderMain(argc, argv); + if (ret < 0) { + _DBG("fail to start loaderMain. candidate process is not created."); + return 1; + } } runtime->dispose(); -- 2.7.4 From 2169c2f2e0c92929f20ba81c4eb0dcd43819a71c Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Fri, 8 Sep 2017 11:24:07 +0900 Subject: [PATCH 05/16] bug-patch:support -am option Change-Id: I3e71bef55eea848e52bf4b417ddcab582b3421f0 --- tools/performance_test.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/performance_test.sh b/tools/performance_test.sh index ed289fb..3519cc4 100755 --- a/tools/performance_test.sh +++ b/tools/performance_test.sh @@ -132,7 +132,7 @@ execute_time_stamp_auto () echo "" #execute dlogstreamer sdb shell "dlogutil -c" - sdb shell "dlogutil -v time AUL LAUNCH|grep -E 'launch.*app_request_to_launchpad_for_uid.*request.*appid|Launching:done]'" >> $STREAM_LOG_FILE & + sdb shell "dlogutil -v time AUL LAUNCH|grep -E 'launch.*app_request_to_launchpad_for_uid.*request.*appid|Launching:done'" >> $STREAM_LOG_FILE & DLOG_STREAMER_PID=$! #execute timestamp /bin/bash ./timestamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE & @@ -145,7 +145,7 @@ execute_time_stamp_auto_memory () echo "[>] Start performance test that applciation launching memory" echo "" sdb shell "dlogutil -c" - sdb shell "dlogutil -v time AUL LAUNCH|grep -E 'app_request_to_launchpad_for_uid.*[SECURE_LOG].*launch.*request|Launching:done'" >> $STREAM_LOG_FILE & + sdb shell "dlogutil -v time AUL LAUNCH|grep -E 'launch.*app_request_to_launchpad_for_uid.*request.*appid|Launching:done'" >> $STREAM_LOG_FILE & DLOG_STREAMER_PID=$! #execute timestamp /bin/bash ./timestamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE & @@ -181,7 +181,7 @@ execute_time_stamp_manual_trace () rm $STREAM_LOG_FILE touch $STREAM_LOG_FILE sdb shell "dlogutil -c" - sdb shell "dlogutil -v time AUL LAUNCH|grep -E 'app_request_to_launchpad_for_uid.*[SECURE_LOG].*launch.*request|Launching:done'" >> $STREAM_LOG_FILE & + sdb shell "dlogutil -v time AUL LAUNCH|grep -E 'launch.*app_request_to_launchpad_for_uid.*request.*appid|Launching:done'" >> $STREAM_LOG_FILE & DLOG_STREAMER_PID=$! #execute timestamp /bin/bash ./timestamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE & @@ -202,7 +202,7 @@ execute_time_stamp_manual_memory () rm $STREAM_LOG_FILE touch $STREAM_LOG_FILE sdb shell "dlogutil -c" - sdb shell "dlogutil -v time AUL LAUNCH|grep -E 'app_request_to_launchpad_for_uid.*[SECURE_LOG].*launch.*request|Launching:done'" >> $STREAM_LOG_FILE & + sdb shell "dlogutil -v time AUL LAUNCH|grep -E 'launch.*app_request_to_launchpad_for_uid.*request.*appid|Launching:done'" >> $STREAM_LOG_FILE & DLOG_STREAMER_PID=$! #execute timestamp /bin/bash ./timestamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE & -- 2.7.4 From b8364639ea341f44381271cc186c4299c317f5a3 Mon Sep 17 00:00:00 2001 From: JongHeon Choi Date: Wed, 19 Jul 2017 14:49:39 +0900 Subject: [PATCH 06/16] Remove caps due to security issue. Apply caps directly in security-config Change-Id: I476d6928065762427d360e22518bf8330266808f --- packaging/dotnet-launcher.spec | 1 - 1 file changed, 1 deletion(-) diff --git a/packaging/dotnet-launcher.spec b/packaging/dotnet-launcher.spec index c9b0b7c..d4045f2 100644 --- a/packaging/dotnet-launcher.spec +++ b/packaging/dotnet-launcher.spec @@ -99,4 +99,3 @@ ln -sf %{_libdir}/libsqlite3.so.0 %{buildroot}%{_native_lib_dir}/libsqlite3.so %if %{use_managed_launcher} %{_bindir}/Tizen.Runtime.dll %endif -%caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/dotnet-launcher -- 2.7.4 From 1f4fe78e4b16ccff778af75592a77f85cca11d5b Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Fri, 3 Nov 2017 13:30:12 +0900 Subject: [PATCH 07/16] add dotnet-launcher to files list to remove build error Change-Id: I88b3dab1dff4a7e30bfe1e6dfaee06b2d8edaf6b --- packaging/dotnet-launcher.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/dotnet-launcher.spec b/packaging/dotnet-launcher.spec index d4045f2..1bebcca 100644 --- a/packaging/dotnet-launcher.spec +++ b/packaging/dotnet-launcher.spec @@ -99,3 +99,4 @@ ln -sf %{_libdir}/libsqlite3.so.0 %{buildroot}%{_native_lib_dir}/libsqlite3.so %if %{use_managed_launcher} %{_bindir}/Tizen.Runtime.dll %endif +%{_bindir}/dotnet-launcher \ No newline at end of file -- 2.7.4 From 74702a30ffb1af33dc4c50ccf8c2c7e9ef19db60 Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Fri, 3 Nov 2017 13:48:30 +0900 Subject: [PATCH 08/16] add cap_sys_admin and cap_setgid to dotnet-launcher to use candidate process Change-Id: I5034c7cca0d967708b69f3495d6665a4f49cf847 --- packaging/dotnet-launcher.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/dotnet-launcher.spec b/packaging/dotnet-launcher.spec index 1bebcca..369d243 100644 --- a/packaging/dotnet-launcher.spec +++ b/packaging/dotnet-launcher.spec @@ -99,4 +99,4 @@ ln -sf %{_libdir}/libsqlite3.so.0 %{buildroot}%{_native_lib_dir}/libsqlite3.so %if %{use_managed_launcher} %{_bindir}/Tizen.Runtime.dll %endif -%{_bindir}/dotnet-launcher \ No newline at end of file +%caps(cap_sys_admin,cap_setgid=ei) %{_bindir}/dotnet-launcher -- 2.7.4 From 3e3d508f3fa04835c34edc480f1cb9be4d3f8867 Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Tue, 14 Nov 2017 15:32:31 +0900 Subject: [PATCH 09/16] add exception handling code for null return Change-Id: I41834f55e6d8d9e33a8d76bead8b281aec2c1a65 --- NativeLauncher/launcher/launcher.cc | 5 ++++- NativeLauncher/launcher/main.cc | 14 +++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/NativeLauncher/launcher/launcher.cc b/NativeLauncher/launcher/launcher.cc index 91c24a1..e0b5ed0 100644 --- a/NativeLauncher/launcher/launcher.cc +++ b/NativeLauncher/launcher/launcher.cc @@ -177,7 +177,10 @@ int LaunchpadAdapterImpl::loaderMain(int argc, char* argv[]) const char* appId, const char* pkgId, const char* pkgType, void* userData) -> int { WITH_SELF(userData) { - self->appInfo.root = std::string(aul_get_app_root_path()); + const char* appRootPath = aul_get_app_root_path(); + if (appRootPath != nullptr) { + self->appInfo.root = std::string(appRootPath); + } self->appInfo.path = appPath; self->appInfo.id = appId; self->appInfo.pkg = pkgId; diff --git a/NativeLauncher/launcher/main.cc b/NativeLauncher/launcher/main.cc index 6fcfb9b..6c1ac12 100644 --- a/NativeLauncher/launcher/main.cc +++ b/NativeLauncher/launcher/main.cc @@ -123,11 +123,15 @@ int main(int argc, char *argv[]) _DBG("pkg : %s", appInfo.pkg.c_str()); _DBG("type : %s", appInfo.type.c_str()); - // The launchpad pass the name of exe file to the first argument. - // For the C# spec, we have to skip this first argument. - - if (runtime->launch(appInfo.id.c_str(), appInfo.root.c_str(), appInfo.path.c_str(), argc-1, argv+1)) - _ERR("Failed to launch"); + // aul_get_app_root_path() can return NULL for error case. + if (appInfo.root.empty()) { + _ERR("Failed to launch. root path is set to NULL"); + } else { + // The launchpad pass the name of exe file to the first argument. + // For the C# spec, we have to skip this first argument. + if (runtime->launch(appInfo.id.c_str(), appInfo.root.c_str(), appInfo.path.c_str(), argc-1, argv+1)) + _ERR("Failed to launch"); + } }; int ret = Launchpad.loaderMain(argc, argv); if (ret < 0) { -- 2.7.4 From b9e2f8612cc34f8b34290ebb7e3c628664b8026f Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Tue, 28 Nov 2017 14:04:34 +0900 Subject: [PATCH 10/16] redirect stdout and stderr to dlog Change-Id: I4c5fe9f676e5fa3f5f8009eac910976e933acffd --- NativeLauncher/inc/utils.h | 2 + NativeLauncher/launcher/dotnet/dotnet_launcher.cc | 4 ++ NativeLauncher/util/utils.cc | 69 ++++++++++++++++++++++- 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/NativeLauncher/inc/utils.h b/NativeLauncher/inc/utils.h index 034b7f3..ac3816e 100644 --- a/NativeLauncher/inc/utils.h +++ b/NativeLauncher/inc/utils.h @@ -43,4 +43,6 @@ std::string joinStrings(const std::vector& strings, const char* con typedef std::function FileReader; void scanFilesInDir(const char* directory, FileReader reader, unsigned int depth); + +int runLoggingThread(); #endif /* __UTILS_H__ */ diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc index db93b4f..f19e5af 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc @@ -335,6 +335,10 @@ int CoreRuntime::launch(const char* appId, const char* root, const char* path, i if (pluginBeforeExecute) pluginBeforeExecute(); + if (runLoggingThread() < 0) { + _ERR("Failed to create logging thread"); + } + #ifdef USE_MANAGED_LAUNCHER runManagedLauncher(appId, probePath.c_str(), tpa.c_str()); diff --git a/NativeLauncher/util/utils.cc b/NativeLauncher/util/utils.cc index 92440f1..d4142eb 100644 --- a/NativeLauncher/util/utils.cc +++ b/NativeLauncher/util/utils.cc @@ -14,12 +14,13 @@ * limitations under the License. */ - +#include #include #include #include #include #include +#include #include #include @@ -30,6 +31,10 @@ #include #include "utils.h" +#include "log.h" + +static int pfd[2]; +static pthread_t loggingThread; bool iCompare(const std::string& a, const std::string& b) { @@ -292,4 +297,64 @@ void scanFilesInDir(const char* directory, FileReader reader, unsigned int depth scanFilesInDir(d.c_str(), reader, depth-1); closedir(dir); -} \ No newline at end of file +} + +static void *stdlog(void*) +{ + ssize_t readSize; + char buf[1024]; + + while ((readSize = read(pfd[0], buf, sizeof buf - 1)) > 0) { + if (buf[readSize - 1] == '\n') { + --readSize; + } + + buf[readSize] = 0; + + _INFO("%s", buf); + } + + return 0; +} + +int runLoggingThread() { // run this function to redirect your output to android log + if (setvbuf(stdout, NULL, _IOLBF, 0) < 0) { + _DBG("fail to make stdout line-buffered"); + return -1; + } + + if (setvbuf(stderr, NULL, _IONBF, 0) < 0) { + _DBG("make stderr unbuffered"); + return -1; + } + + /* create the pipe and redirect stdout and stderr */ + if (pipe(pfd) < 0) { + _DBG("fail to create pipe for logging"); + return -1; + } + + if (dup2(pfd[1], fileno(stdout)) == -1) { + _DBG("fail to duplicate fd to stdout"); + return -1; + } + + if (dup2(pfd[1], fileno(stderr)) == -1) { + _DBG("fail to duplicate fd to stderr"); + return -1; + } + + /* spawn the logging thread */ + if (pthread_create(&loggingThread, 0, stdlog, 0) != 0) { + _DBG("fail to create pthread"); + return -1; + } + + if (pthread_detach(loggingThread) != 0) { + _DBG("fail to detach pthread"); + return -1; + } + + return 0; +} + -- 2.7.4 From 47b44f39311e68172008c9ec9ee4a3cb9a53599d Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Tue, 5 Dec 2017 14:24:53 +0900 Subject: [PATCH 11/16] Coreclr needs original executable dll path not ni file path for dll loading. ni file searching is automatically done in the inside of coreclr Change-Id: I14fc7629431a3b082da06189dd2031a61b571afa --- NativeLauncher/launcher/dotnet/dotnet_launcher.cc | 9 --------- 1 file changed, 9 deletions(-) diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc index f19e5af..36df3ca 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc @@ -344,15 +344,6 @@ int CoreRuntime::launch(const char* appId, const char* root, const char* path, i bool success = false; if (launchFunction != nullptr) { - std::string cppPath(path); - - if (isManagedAssembly(cppPath) && !isNativeImage(cppPath)) { - size_t extindex = cppPath.size() - 4; - cppPath = cppPath.substr(0, extindex) + ".ni" + cppPath.substr(extindex, 4); - if (!fileNotExist(cppPath)) - path = cppPath.c_str(); - } - success = launchFunction(root, path, argc, argv); if (!success) _ERR("Failed to launch Application %s", path); -- 2.7.4 From 15df655ca41ee7e06d9e0ab7e35d0ca708a07c93 Mon Sep 17 00:00:00 2001 From: Konstantin Baladurin Date: Wed, 6 Dec 2017 09:18:22 +0300 Subject: [PATCH 12/16] Add option to enable clang Asan build. Now we can add '--define "asan_enabled 1"' option for gbs to enable Asan build. Change-Id: Iac347386c26e3a72aa1275c312550df809aff003 --- NativeLauncher/CMakeLists.txt | 15 +++++++++++---- packaging/dotnet-launcher.spec | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/NativeLauncher/CMakeLists.txt b/NativeLauncher/CMakeLists.txt index 6d78c6f..166e542 100644 --- a/NativeLauncher/CMakeLists.txt +++ b/NativeLauncher/CMakeLists.txt @@ -52,14 +52,21 @@ IF(NOT_USE_FUNCTION) ENDIF(NOT_USE_FUNCTION) -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -pthread -std=c++11 -Wl,--no-as-needed -ggdb") -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" ) +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -pthread -std=c++11 -ggdb") #SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden") #SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIE") -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fdata-sections -ffunction-sections -Wl,--gc-sections") +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fdata-sections -ffunction-sections") SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -D_FILE_OFFSET_BITS=64") #SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DLAUNCHING_TIME_MEASURE") +IF(ASAN_ENABLED) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fno-omit-frame-pointer -fsanitize=address") +ELSE(ASAN_ENABLED) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs") + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,--no-as-needed") + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,--gc-sections") +ENDIF(ASAN_ENABLED) + SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") SET(CMAKE_CXX_FLAGS_DEBUG "-O2 -g") SET(CMAKE_CXX_FLAGS_RELEASE "-O2") @@ -129,4 +136,4 @@ IF(NOT DEFINED NO_TIZEN) INSTALL(FILES dotnet.loader DESTINATION ${LOADERDIR}) INSTALL(FILES dotnet.launcher DESTINATION ${LOADERDIR}) INSTALL(FILES dotnet.debugger DESTINATION ${LOADERDIR}) -ENDIF(NOT DEFINED NO_TIZEN) +ENDIF(NOT DEFINED NO_TIZEN) \ No newline at end of file diff --git a/packaging/dotnet-launcher.spec b/packaging/dotnet-launcher.spec index 369d243..66bb45d 100644 --- a/packaging/dotnet-launcher.spec +++ b/packaging/dotnet-launcher.spec @@ -20,6 +20,11 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: aul-devel BuildRequires: dotnet-build-tools +%if 0%{?asan_enabled} +BuildRequires: clang >= 3.8 +BuildRequires: compiler-rt +%endif + Requires: aul Requires: launchpad @@ -52,8 +57,24 @@ Launchpad plugin for launching dotnet apps %endif %build + +%if 0%{?asan_enabled} +%define _dotnet_build_conf Debug +export CFLAGS=" --target=%{_host} " +export CXXFLAGS=" --target=%{_host} " +%ifarch %{ix86} +export CFLAGS=$(echo $CFLAGS | sed -e 's/--target=i686/--target=i586/') +export CXXFLAGS=$(echo $CXXFLAGS | sed -e 's/--target=i686/--target=i586/') +%endif +%endif + cmake \ -DCMAKE_INSTALL_PREFIX=%{_prefix} \ +%if 0%{?asan_enabled} + -DCMAKE_C_COMPILER=clang \ + -DCMAKE_CXX_COMPILER=clang++ \ + -DASAN_ENABLED=TRUE \ +%endif -DPACKAGE_NAME=%{name} \ -DLIBDIR=%{_libdir} \ -DBINDIR=%{_bindir} \ -- 2.7.4 From 2d6890e13b6edb6c503b7e90e2a075bb0b553ff4 Mon Sep 17 00:00:00 2001 From: chunseok lee Date: Thu, 14 Dec 2017 16:03:37 +0900 Subject: [PATCH 13/16] Add COMPlus_ZapDisable env variable This patch is required to enable gdbjit with NI files Change-Id: Ic470761589480722fcae79720cd0bf6fe1004bbf Signed-off-by: chunseok lee (cherry picked from commit 4f26ced1190958c415fadc1356e54ae19920b4ae) --- NativeLauncher/dotnet.debugger | 1 + 1 file changed, 1 insertion(+) diff --git a/NativeLauncher/dotnet.debugger b/NativeLauncher/dotnet.debugger index 6f57cde..7a89927 100644 --- a/NativeLauncher/dotnet.debugger +++ b/NativeLauncher/dotnet.debugger @@ -4,3 +4,4 @@ EXE /home/owner/share/tmp/sdk_tools/lldb/bin/lldb-server APP_TYPE dotnet EXTRA_KEY __DLP_DEBUG_ARG__ EXTRA_ENV CORECLR_GDBJIT +EXTRA_ENV COMPlus_ZapDisable -- 2.7.4 From b93c8563bbbbae4b2152561053a8bb83fdf4efae Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Wed, 13 Dec 2017 16:30:12 +0900 Subject: [PATCH 14/16] remove module/function name from stderr log Change-Id: I48980d8579ed68a54460a795b550e853a80e67c5 --- NativeLauncher/inc/log.h | 10 ++++++++++ NativeLauncher/util/utils.cc | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/NativeLauncher/inc/log.h b/NativeLauncher/inc/log.h index 5769204..3315f8e 100644 --- a/NativeLauncher/inc/log.h +++ b/NativeLauncher/inc/log.h @@ -19,11 +19,17 @@ #ifndef NO_TIZEN #include +#define LOGX(fmt, arg...) \ + ({ do { \ + dlog_print(DLOG_ERROR, LOG_TAG, fmt, ##arg); \ + } while (0); }) + #else #include #define LOGE(fmt, args...) printf(fmt, ##args) #define LOGD(fmt, args...) printf(fmt, ##args) #define LOGI(fmt, args...) printf(fmt, ##args) +#define LOGX(fmt, args...) printf(fmt, ##args) #endif #ifdef LOG_TAG @@ -43,4 +49,8 @@ #define _INFO(fmt, args...) LOGI(fmt "\n", ##args) #endif +#ifndef _ERRX +#define _ERRX(fmt, args...) LOGX(fmt "\n", ##args) +#endif + #endif /* __LOG_H__ */ diff --git a/NativeLauncher/util/utils.cc b/NativeLauncher/util/utils.cc index d4142eb..f5b9406 100644 --- a/NativeLauncher/util/utils.cc +++ b/NativeLauncher/util/utils.cc @@ -311,7 +311,7 @@ static void *stdlog(void*) buf[readSize] = 0; - _INFO("%s", buf); + _ERRX("%s", buf); } return 0; -- 2.7.4 From 15bdbf0a11617b306fd5690fe585776c60c26056 Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Fri, 15 Dec 2017 08:04:23 +0900 Subject: [PATCH 15/16] Remove code related to %caps. caps is handled by security team. Change-Id: I8998e71d86dc6436bcd262cde74da1a6a3cfdd76 --- packaging/dotnet-launcher.spec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packaging/dotnet-launcher.spec b/packaging/dotnet-launcher.spec index 369d243..ae0c072 100644 --- a/packaging/dotnet-launcher.spec +++ b/packaging/dotnet-launcher.spec @@ -99,4 +99,5 @@ ln -sf %{_libdir}/libsqlite3.so.0 %{buildroot}%{_native_lib_dir}/libsqlite3.so %if %{use_managed_launcher} %{_bindir}/Tizen.Runtime.dll %endif -%caps(cap_sys_admin,cap_setgid=ei) %{_bindir}/dotnet-launcher +%{_bindir}/dotnet-launcher + -- 2.7.4 From 3e0666401c881951d4bf2312d657d4ba491cd685 Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Wed, 24 Jan 2018 11:13:20 +0900 Subject: [PATCH 16/16] add interval between each crossgen Change-Id: I9688331704322452cebe0a454ca03cf6bcf6d9e9 (cherry picked from commit 1b1fd307e364a6a6088f0aff31158035b8d6fb85) --- NativeLauncher/installer-plugin/common.cc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/NativeLauncher/installer-plugin/common.cc b/NativeLauncher/installer-plugin/common.cc index f7fc71b..f1d212e 100644 --- a/NativeLauncher/installer-plugin/common.cc +++ b/NativeLauncher/installer-plugin/common.cc @@ -35,6 +35,8 @@ #include #include +#include + #include "common.h" #ifdef LOG_TAG @@ -338,6 +340,17 @@ int createNiUnderPkgRoot(const char* pkgName) if (getRootPath(pkgName, pkgRoot) < 0) return 1; + // get interval value + const char* intervalFile = "/usr/share/dotnet.tizen/lib/crossgen_interval.txt"; + int interval = 0; + std::ifstream inFile(intervalFile); + if (inFile) { + _INFO("crossgen_interval.txt is found"); + inFile >> interval; + } else { + _INFO("fail to read crossgen_interval.txt file"); + } + std::string binDir = concatPath(pkgRoot, "bin"); std::string libDir = concatPath(pkgRoot, "lib"); _INFO("bindir : %s", binDir.c_str()); @@ -350,8 +363,12 @@ int createNiUnderPkgRoot(const char* pkgName) // change smack label for generated ni file. std::string label = "User::Pkg::" + std::string(pkgName) + "::RO"; - createNiUnderDirs(paths, 2, [label](const char* ni) { + createNiUnderDirs(paths, 2, [label, interval](const char* ni) { smack_(ni, label.c_str()); + if (interval != 0) { + _INFO("sleep %d usec", interval); + usleep(interval); + } }); return 0; -- 2.7.4