diff --git a/.github/workflows/ci.py b/.github/workflows/ci.py index d9e8ce771..ab791df15 100644 --- a/.github/workflows/ci.py +++ b/.github/workflows/ci.py @@ -20,6 +20,7 @@ NERD_URL = 'https://github.com/ryanoasis/nerd-fonts/releases/latest/download/Ner is_bundle = os.environ.get('KITTY_BUNDLE') == '1' is_codeql = os.environ.get('KITTY_CODEQL') == '1' is_macos = 'darwin' in sys.platform.lower() +running_under_sanitizer = os.environ.get('KITTY_SANITIZE') == '1' SW = '' @@ -134,10 +135,8 @@ def install_deps() -> None: def build_kitty() -> None: python = shutil.which('python3') if is_bundle else sys.executable cmd = f'{python} setup.py build --verbose' - if os.environ.get('KITTY_SANITIZE') == '1': + if running_under_sanitizer: cmd += ' --debug --sanitize' - elif is_macos: - cmd += ' --debug' # for better crash report to debug SIGILL issue run(cmd) @@ -145,6 +144,8 @@ def test_kitty() -> None: if is_macos: run('ulimit -c unlimited') run('sudo chmod -R 777 /cores') + if running_under_sanitizer: + os.environ['MallocNanoZone'] = '0' run('./test.py', print_crash_reports=True) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1cbf4f6b0..95ea55b4d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -143,6 +143,7 @@ jobs: os: [ubuntu-latest, macos-latest] env: KITTY_BUNDLE: 1 + KITTY_SANITIZE: 1 steps: - name: Checkout source code uses: actions/checkout@v6.0.3 diff --git a/kitty_tests/check_build.py b/kitty_tests/check_build.py index dfc9ed3a6..956154032 100644 --- a/kitty_tests/check_build.py +++ b/kitty_tests/check_build.py @@ -127,8 +127,10 @@ class TestBuild(BaseTest): exe = os.path.join(tdir, 'dictation_probe') with open(src, 'w') as f: f.write(probe) + nm = subprocess.run(['nm', '-g', cocoa_module], capture_output=True, text=True) + asan_flags = ['-fsanitize=address,undefined', '-fno-omit-frame-pointer'] if '__asan_init' in nm.stdout else [] cp = subprocess.run( - ['clang', '-framework', 'AppKit', src, '-o', exe], + ['clang', '-framework', 'AppKit'] + asan_flags + [src, '-o', exe], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True ) self.assertEqual(cp.returncode, 0, cp.stdout)