diff --git a/src/ApiService/ApiService/onefuzzlib/Extension.cs b/src/ApiService/ApiService/onefuzzlib/Extension.cs index a9bc50885..bd5bbe75b 100644 --- a/src/ApiService/ApiService/onefuzzlib/Extension.cs +++ b/src/ApiService/ApiService/onefuzzlib/Extension.cs @@ -303,7 +303,7 @@ public class Extensions : IExtensions { urlsUpdated.Add(toolsAzCopy); urlsUpdated.Add(toolsSetup); - var toExecuteCmd = $"sh setup.sh {mode.ToString().ToLowerInvariant()}"; + var toExecuteCmd = $"bash setup.sh {mode.ToString().ToLowerInvariant()}"; var extensionSettings = JsonSerializer.Serialize(new { CommandToExecute = toExecuteCmd, FileUris = urlsUpdated }, _extensionSerializerOptions); var extension = new VMExtensionWrapper { diff --git a/src/agent/onefuzz-task/src/tasks/report/dotnet/common.rs b/src/agent/onefuzz-task/src/tasks/report/dotnet/common.rs index f0cfcf47c..69b9d4f0c 100644 --- a/src/agent/onefuzz-task/src/tasks/report/dotnet/common.rs +++ b/src/agent/onefuzz-task/src/tasks/report/dotnet/common.rs @@ -27,12 +27,18 @@ pub async fn collect_exception_info( } }; - let exception = dump.exception().await?; + let exception = dump.exception().await; // Remove temp dir cooperatively. spawn_blocking(move || tmp_dir).await?; - Ok(exception) + match exception { + Ok(r) => Ok(Some(r)), + Err(e) => { + error!("unable to extract exception info: {}", e); + Ok(None) + } + } } const DUMP_FILE_NAME: &str = "tmp.dmp"; @@ -43,7 +49,7 @@ const MINIDUMP_TYPE_VAR: &str = "COMPlus_DbgMiniDumpType"; const MINIDUMP_NAME_VAR: &str = "COMPlus_DbgMiniDumpName"; const MINIDUMP_ENABLE: &str = "1"; -const MINIDUMP_TYPE_HEAP: &str = "2"; +const MINIDUMP_TYPE_FULL: &str = "4"; // Invoke target with .NET runtime environment vars set to create minidumps. // @@ -64,7 +70,7 @@ async fn collect_dump( // Set `dotnet` environment vars to enable saving minidumps on crash. cmd.env(ENABLE_MINIDUMP_VAR, MINIDUMP_ENABLE); - cmd.env(MINIDUMP_TYPE_VAR, MINIDUMP_TYPE_HEAP); + cmd.env(MINIDUMP_TYPE_VAR, MINIDUMP_TYPE_FULL); cmd.env(MINIDUMP_NAME_VAR, dump_path); let mut child = cmd.spawn()?; @@ -97,12 +103,10 @@ impl DotnetDumpFile { Self { path } } - pub async fn exception(&self) -> Result> { + pub async fn exception(&self) -> Result { let output = self.exec_sos_command(SOS_PRINT_EXCEPTION).await?; let text = String::from_utf8_lossy(&output.stdout); - let exception = parse_sos_print_exception_output(&text).ok(); - - Ok(exception) + parse_sos_print_exception_output(&text) } async fn exec_sos_command(&self, sos_cmd: &str) -> Result { @@ -209,7 +213,8 @@ pub fn parse_sos_print_exception_output(text: &str) -> Result /dev/null 2> /dev/null; then curl --retry 10 -sSL https://dot.net/v1/dotnet-install.sh -o dotnet-install.sh 2>&1 | logger -s -i -t 'onefuzz-curl-dotnet-install' chmod +x dotnet-install.sh - logger "running dotnet install" - /bin/bash ./dotnet-install.sh --version "$DOTNET_VERSION" --install-dir "$DOTNET_ROOT" 2>&1 | logger -s -i -t 'onefuzz-dotnet-setup' + for version in "${DOTNET_VERSIONS[@]}"; do + logger "running dotnet install $version" + /bin/bash ./dotnet-install.sh --version "$version" --install-dir "$DOTNET_ROOT" 2>&1 | logger -s -i -t 'onefuzz-dotnet-setup' + done rm dotnet-install.sh logger "install dotnet tools" pushd "$DOTNET_ROOT" ls -lah 2>&1 | logger -s -i -t 'onefuzz-dotnet-tools' - "$DOTNET_ROOT"/dotnet tool install dotnet-dump --version 6.0.328102 --tool-path /onefuzz/tools 2>&1 | logger -s -i -t 'onefuzz-dotnet-tools' - "$DOTNET_ROOT"/dotnet tool install dotnet-coverage --version 17.3.6 --tool-path /onefuzz/tools 2>&1 | logger -s -i -t 'onefuzz-dotnet-tools' - "$DOTNET_ROOT"/dotnet tool install dotnet-sos --version 6.0.328102 --tool-path /onefuzz/tools 2>&1 | logger -s -i -t 'onefuzz-dotnet-tools' + "$DOTNET_ROOT"/dotnet tool install dotnet-dump --version 6.0.351802 --tool-path /onefuzz/tools 2>&1 | logger -s -i -t 'onefuzz-dotnet-tools' + "$DOTNET_ROOT"/dotnet tool install dotnet-coverage --version 17.5 --tool-path /onefuzz/tools 2>&1 | logger -s -i -t 'onefuzz-dotnet-tools' + "$DOTNET_ROOT"/dotnet tool install dotnet-sos --version 6.0.351802 --tool-path /onefuzz/tools 2>&1 | logger -s -i -t 'onefuzz-dotnet-tools' popd fi diff --git a/src/runtime-tools/win64/onefuzz.ps1 b/src/runtime-tools/win64/onefuzz.ps1 index df6086fa8..16e4717e1 100644 --- a/src/runtime-tools/win64/onefuzz.ps1 +++ b/src/runtime-tools/win64/onefuzz.ps1 @@ -6,7 +6,7 @@ $env:ONEFUZZ_ROOT = "C:\onefuzz" $env:ONEFUZZ_TOOLS = "C:\onefuzz\tools" $env:LLVM_SYMBOLIZER_PATH = "llvm-symbolizer" $env:RUST_LOG = "info" -$env:DOTNET_VERSION = "7.0.100" +$env:DOTNET_VERSIONS = "7.0.100;6.0.403" # Set a session and machine scoped env var $env:DOTNET_ROOT = "c:\onefuzz\tools\dotnet" [Environment]::SetEnvironmentVariable("DOTNET_ROOT", $env:DOTNET_ROOT, "Machine") @@ -19,10 +19,10 @@ function log ($message) { } function Setup-Silent-Notification { - # https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/registry-entries-for-silent-process-exit - log "installing registry key for silent termination notification of onefuzz-agent" - reg import c:\onefuzz\tools\win64\onefuzz-silent-exit.reg - log "done importing registry key" + # https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/registry-entries-for-silent-process-exit + log "installing registry key for silent termination notification of onefuzz-agent" + reg import c:\onefuzz\tools\win64\onefuzz-silent-exit.reg + log "done importing registry key" } function Uninstall-OneDrive { @@ -31,13 +31,13 @@ function Uninstall-OneDrive { Unregister-ScheduledTask -TaskName *OneDrive* -Confirm:$false if (Test-Path $env:windir\SysWOW64\OneDriveSetup.exe) { - log "uninstalling onedrive from syswow64" - Start-Process -FilePath $env:windir\SysWOW64\OneDriveSetup.exe -ArgumentList /uninstall + log "uninstalling onedrive from syswow64" + Start-Process -FilePath $env:windir\SysWOW64\OneDriveSetup.exe -ArgumentList /uninstall } if (Test-Path $env:windir\System32\OneDriveSetup.exe) { - log "uninstalling onedrive from system32" - Start-Process -FilePath $env:windir\System32\OneDriveSetup.exe -ArgumentList /uninstall + log "uninstalling onedrive from system32" + Start-Process -FilePath $env:windir\System32\OneDriveSetup.exe -ArgumentList /uninstall } } @@ -173,17 +173,21 @@ function Install-VCRedist { log "installing VC Redist: done" } -function Install-Dotnet([string]$Version, [string]$InstallDir, [string]$ToolsDir) { - log "Installing dotnet to ${InstallDir}" - Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile 'dotnet-install.ps1' - ./dotnet-install.ps1 -Version $Version -InstallDir $InstallDir - Remove-Item ./dotnet-install.ps1 - log "Installing dotnet: done" +function Install-Dotnet([string]$Versions, [string]$InstallDir, [string]$ToolsDir) { + $Versions -Split ';' | ForEach-Object { + $Version = $_ + log "Installing dotnet ${Version} to ${InstallDir}" + Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile 'dotnet-install.ps1' + ./dotnet-install.ps1 -Version $Version -InstallDir $InstallDir + Remove-Item ./dotnet-install.ps1 + log "Installing dotnet ${Version}: done" + } + log "Installing dotnet tools to ${ToolsDir}" Push-Location $InstallDir - ./dotnet.exe tool install dotnet-dump --version 6.0.328102 --tool-path $ToolsDir - ./dotnet.exe tool install dotnet-coverage --version 17.3.6 --tool-path $ToolsDir - ./dotnet.exe tool install dotnet-sos --version 6.0.328102 --tool-path $ToolsDir + ./dotnet.exe tool install dotnet-dump --version 6.0.351802 --tool-path $ToolsDir + ./dotnet.exe tool install dotnet-coverage --version 17.5.0 --tool-path $ToolsDir + ./dotnet.exe tool install dotnet-sos --version 6.0.351802 --tool-path $ToolsDir Pop-Location log "Installing dotnet tools: done" } diff --git a/src/runtime-tools/win64/setup.ps1 b/src/runtime-tools/win64/setup.ps1 index 163451c0b..e23f88530 100644 --- a/src/runtime-tools/win64/setup.ps1 +++ b/src/runtime-tools/win64/setup.ps1 @@ -69,7 +69,7 @@ function Install-OnefuzzSetup { Enable-SSH Install-OnBoot Install-VCRedist - Install-Dotnet -Version $env:DOTNET_VERSION -InstallDir $env:DOTNET_ROOT -ToolsDir $env:ONEFUZZ_TOOLS + Install-Dotnet -Version $env:DOTNET_VERSIONS -InstallDir $env:DOTNET_ROOT -ToolsDir $env:ONEFUZZ_TOOLS Setup-Silent-Notification log "onefuzz: setup done" }