Enable ASAN for macOS CI builds in ci.py

This commit is contained in:
copilot-swe-agent[bot] 2026-06-24 04:14:27 +00:00 committed by Kovid Goyal
parent 903d2a5335
commit bf7689b211
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 8 additions and 4 deletions

View file

@ -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)

View file

@ -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

View file

@ -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)