Skip to content

[6.3]Ensure the string passed to PathIsRelativeW is null terminated#2606

Open
rintaro wants to merge 1 commit intoswiftlang:release/6.3from
rintaro:6.3-flakey-compdb
Open

[6.3]Ensure the string passed to PathIsRelativeW is null terminated#2606
rintaro wants to merge 1 commit intoswiftlang:release/6.3from
rintaro:6.3-flakey-compdb

Conversation

@rintaro
Copy link
Copy Markdown
Member

@rintaro rintaro commented Apr 13, 2026

Cherry-pick #2361 into release/6.3

  • Explanation: PathIsRelativeW in Windows requires a null terminated string. Ensure to pass null terminated C string encoded with UTF16. This prevents crashes and fixes flaky tests
  • Scope: compilation database project for Windows
  • Risk: Low. Small obvious changes, only in Windows
  • Issue: rdar://165006835
  • Testing: Passes current test suite.
  • Reviewer: @bnbarham as the original author, @compnerd, and @ahoppen

`CompilationDatabaseTests` have been flakey on Windows since
swiftlang#2334. This didn't really
introduce the failure though - it just added tests that now catch it.

The underlying cause is that `filename.isAbsolutePath` sometimes returns
`true` for a relative path, which then causes the CWD to be prepended
instead of the given `compileCommandsDirectory`.

`PathIsRelativeW` requires a null terminated string, so presumably we
were hitting junk after the initial path that sometimes turned it into
an absolute path. From the Windows docs:
> A pointer to a null-terminated string of maximum length MAX_PATH that
contains the path to search.

Fixes swiftlang#2360
Resolves rdar://165006835

(cherry picked from commit b3cb43f)
@rintaro rintaro changed the title Ensure the string passed to PathIsRelativeW is null terminated [6.3]Ensure the string passed to PathIsRelativeW is null terminated Apr 13, 2026
@rintaro
Copy link
Copy Markdown
Member Author

rintaro commented Apr 13, 2026

@swift-ci Please test

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.

2 participants