Skip to content

Conversation

@CedricGuillemet
Copy link
Contributor

@CedricGuillemet CedricGuillemet commented Oct 27, 2025

Enable Address sanitizer as pointed by #1557

  • Add macOS, Windows and Linux sanitizer builds
  • up ndk to v28
  • misc build fixes
  • fix reported memory leaks and bugs

Memleaks + CI issue : #1575

@matthargett
Copy link

something I ran into 5 years ago that's still a big challenge: getting ASan to run on Android simulator/device is very very finicky. If you manage to figure it out, it would be a huge help! :D if that's what you get stuck on, then I'd say that getting v8 integration coverage on a non-Android platform could be a good fallback that would likely give the effectively the same feedback loop.

@CedricGuillemet
Copy link
Contributor Author

@matthargett I think you are referring to ASAN images not available and missing .so :)

@CedricGuillemet CedricGuillemet marked this pull request as ready for review November 13, 2025 08:53
@CedricGuillemet CedricGuillemet changed the title enable sanitizers for macOS, Linux and Android Enable sanitizers for macOS, Linux Nov 14, 2025
@CedricGuillemet CedricGuillemet changed the title Enable sanitizers for macOS, Linux Enable sanitizers for macOS, Linux, Windows Nov 19, 2025
Copy link
Contributor

@bghgary bghgary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Some small comments.

Comment on lines +38 to +42
- script: |
cd build/Apps/UnitTests
xvfb-run ./UnitTests
displayName: 'Unit Tests'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you intend to move this?

Comment on lines +69 to +84
- powershell: |
$vs = vswhere -latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
$msvc = Get-ChildItem "$vs\VC\Tools\MSVC" | Sort-Object Name -Descending | Select-Object -First 1
$asan = "$($msvc.FullName)\bin\Hostx64\x64"
$destinations = @(
"build${{ variables.solutionName }}\Apps\Playground\RelWithDebInfo",
"build${{ variables.solutionName }}\Apps\UnitTests\RelWithDebInfo"
)
foreach ($dest in $destinations) {
Get-ChildItem "$asan\clang_rt.asan_*.dll" |
Copy-Item -Destination $dest
}
displayName: "Copy ASAN runtime DLLs"
condition: ${{ parameters.enableSanitizers }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for now. Consider doing this inside CMake since it seems like it's part of the build.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. These dll are in PATH when debugging/testing with Visual Studio.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, maybe we should do the same and add them to the path? Do you know what adds them to the path?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Maybe this file should go in the source and copied with the app so that you don't have to do the ../../.. thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

Comment on lines +37 to +38
// context is a monitoredResource managed by the GC while Canvas::Impl is managed by the app. Make sure the canvas impl is destroyed after all monitoredResources are.
std::shared_ptr<Canvas::Impl> m_impl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know this code well. Is it okay to have different lifetime management for this?

# MSVC only supports AddressSanitizer
add_compile_options(/fsanitize=address /Zi /Od)
else()
message(WARNING "Sanitizers not supported on this compiler.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be an error instead of warning? I would think this is a mistake if someone tried to enable sanitizers on a platform that doesn't allow it.

Comment on lines +70 to +84
- template: .github/jobs/win32.yml
parameters:
name: Win32_x64_D3D12_Sanitizers
vmImage: 'windows-latest'
platform: x64
graphics_api: D3D12
enableSanitizers: true

- template: .github/jobs/win32.yml
parameters:
name: Win32_x64_V8_D3D11_Sanitizers
vmImage: 'windows-latest'
platform: x64
napiType: V8
enableSanitizers: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much time does this add to the CI if any? Do we need to run both with sanitizers and without?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 should be enough, indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants