Fix the slashes when setting the ZapBBInstrDir (#19858)
authorMichelle McDaniel <adiaaida@gmail.com>
Fri, 7 Sep 2018 20:08:25 +0000 (13:08 -0700)
committerGitHub <noreply@github.com>
Fri, 7 Sep 2018 20:08:25 +0000 (13:08 -0700)
In OpenMethodProfileDataLogFile, we try to set the directory and path for the .ibc files using windows slashes (\). This causes this code to fail on Linux, which uses forward slashes. This is particularly a problem when setting COMPlus_ZapBBInstrDir, which takes that environment variable and attempts to find the name of the file using wcsrchr(assemblyPath, '\'). This causes a crash on linux when collecting IBC counts. The fix is to ifdef it for linux to use the correct path separator.

This change also includes a fix to change the code for checking if IbcTuning is set to use == instead of -eq which was causing a failure in the build that was ignored.

build.sh
src/vm/ceeload.cpp

index 6c40251..f491063 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -454,7 +454,7 @@ build_CoreLib()
 
     # Invoke MSBuild
     __ExtraBuildArgs=""
-    if [[ "$__IbcTuning" -eq "" ]]; then
+    if [[ "$__IbcTuning" == "" ]]; then
         __ExtraBuildArgs="$__ExtraBuildArgs -OptimizationDataDir=\"$__PackagesDir/optimization.$__BuildOS-$__BuildArch.IBC.CoreCLR/$__IbcOptDataVersion/data/\""
         __ExtraBuildArgs="$__ExtraBuildArgs -EnableProfileGuidedOptimization=true"
     fi
index 19c5167..ffdaea8 100644 (file)
@@ -11336,14 +11336,14 @@ HANDLE Module::OpenMethodProfileDataLogFile(GUID mvid)
         path.Set(assemblyPath);                         // no, then put it beside the IL dll
     }
     else {
-        LPCWSTR assemblyFileName = wcsrchr(assemblyPath, '\\'); 
+        LPCWSTR assemblyFileName = wcsrchr(assemblyPath, DIRECTORY_SEPARATOR_CHAR_W);
         if (assemblyFileName)
             assemblyFileName++;                         // skip past the \ char
         else 
             assemblyFileName = assemblyPath;
 
         path.Set(ibcDir);                               // yes, put it in the directory, named with the assembly name.
-        path.Append('\\');
+        path.Append(DIRECTORY_SEPARATOR_CHAR_W);
         path.Append(assemblyFileName);
     }