Skip to content

[tools] Fix race condition in assembly-preparer Makefile - #25762

Merged
rolfbjarne merged 1 commit into
mainfrom
rolfbjarne/fix-assembly-preparer-makefile-race
Jun 23, 2026
Merged

rolfbjarne merged 1 commit into
mainfrom
rolfbjarne/fix-assembly-preparer-makefile-race

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

The assembly-preparer.csproj builds for two target frameworks (netstandard2.0 and net10.0) in parallel. Both TFMs invoke make generated-files concurrently via a BeforeTargets="CoreCompile" target. Each make invocation triggers a rebuild of assembly-preparer.csproj.inc (via the pattern rule in mk/rules.mk), which runs create-makefile-fragment.sh. Two concurrent instances of this script share the same intermediate files (.inputs), causing one to corrupt or delete files the other needs. This results in a corrupt .inc file and a *** missing separator make error.

The fix wraps the -include assembly-preparer.csproj.inc in an ifneq ($(MAKECMDGOALS),generated-files) guard, so the .inc file is not rebuilt when the target is generated-files -- since it is not needed for that target anyway.

🤖 Pull request created by Copilot

When MSBuild builds assembly-preparer for multiple target frameworks in
parallel, both TFMs invoke 'make generated-files' concurrently. Each make
invocation tries to rebuild assembly-preparer.csproj.inc (via the pattern
rule in mk/rules.mk), which runs create-makefile-fragment.sh. Two
concurrent instances of this script share intermediate files (.inputs),
causing one to delete files the other needs, resulting in a corrupt .inc
file and a 'missing separator' make error.

Fix by skipping the -include of the .inc file when the target is
generated-files, since that target doesn't need the dependency variable
from the .inc file.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne
rolfbjarne marked this pull request as ready for review June 22, 2026 18:01
Copilot AI review requested due to automatic review settings June 22, 2026 18:01
@rolfbjarne
rolfbjarne enabled auto-merge (squash) June 22, 2026 18:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a build race in tools/assembly-preparer where MSBuild can invoke make generated-files concurrently for multiple TFMs, causing assembly-preparer.csproj.inc regeneration to collide and produce a corrupt .inc file / Make parse error.

Changes:

  • Adds a MAKECMDGOALS guard to avoid -include assembly-preparer.csproj.inc when the requested goal is generated-files.
  • Documents why the include is conditionally skipped (concurrent MSBuild invocations + non-concurrent-safe generator script intermediates).

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #61c5eac] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 61c5eacd32a4457c608599dd08e17751b68c9a35 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #61c5eac] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 61c5eacd32a4457c608599dd08e17751b68c9a35 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 61c5eacd32a4457c608599dd08e17751b68c9a35 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #61c5eac] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 61c5eacd32a4457c608599dd08e17751b68c9a35 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [CI Build #61c5eac] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 207 tests passed 🎉

Tests counts

✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 20 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 20 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ monotouch (tvOS): All 20 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Monterey (12): All 5 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

✅ Linux build succeeded

Pipeline on Agent
Hash: 61c5eacd32a4457c608599dd08e17751b68c9a35 [PR build]

@rolfbjarne
rolfbjarne merged commit b6d2150 into main Jun 23, 2026
62 checks passed
@rolfbjarne
rolfbjarne deleted the rolfbjarne/fix-assembly-preparer-makefile-race branch June 23, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants