Mono AOT compiler crashes with: condition `p - buf < buf_size' not met

Open
#112,850 3 comments 0 reactions 1 assignee View on GitHub

@BrzVlad is already working on this.

Since Aug 23, 2025.

Assessment

This issue has not been assessed yet.

Description

area-Codegen-AOT-mono os-maccatalyst
Description

Crash when AOT-compiling my code.

Reproduction Steps

Clone https://github.com/rolfbjarne/bug-repros and run ./2025-02-24-mono-aot-crash/repro.sh:

$ ./2025-02-24-mono-aot-crash/repro.sh
++ dirname ./2025-02-24-mono-aot-crash/repro.sh
+ cd ./2025-02-24-mono-aot-crash
+ /usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-arm64.Cross.maccatalyst-arm64/9.0.0/Sdk/../tools/mono-aot-cross --path=./linked --aot=mtriple=arm64-apple-ios15.0-macabi,data-outfile=./monotouchtest.aotdata,static,asmonly,dedup-skip,direct-icalls,full,soft-debug,dwarfdebug,no-direct-calls,outfile=./monotouchtest.dll.s --debug -O=gsharedvt ./linked/monotouchtest.dll
Mono Ahead of Time compiler - compiling assembly [...]/bug-repros/2025-02-24-mono-aot-crash/linked/monotouchtest.dll
AOTID 1085CE5E-EB01-C3CC-909A-0C25AB930848
* Assertion at /Users/runner/work/1/s/src/mono/mono/mini/aot-compiler.c:8037, condition `p - buf < buf_size' not met

./2025-02-24-mono-aot-crash/repro.sh: line 9: 96539 Abort trap: 6           /usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-arm64.Cross.maccatalyst-arm64/9.0.0/Sdk/../tools/mono-aot-cross --path=./linked --aot=mtriple=arm64-apple-ios15.0-macabi,data-outfile=./monotouchtest.aotdata,static,asmonly,dedup-skip,direct-icalls,full,soft-debug,dwarfdebug,no-direct-calls,outfile=./monotouchtest.dll.s --debug -O=gsharedvt ./linked/monotouchtest.dll

Note: you'll probably have to adjust the path to the mono-aot-cross binary in the script.

Expected behavior

No crash.

Actual behavior

Crash.

Crash report: https://github.com/rolfbjarne/bug-repros/blob/main/2025-02-24-mono-aot-crash/mono-aot-cross-2025-02-24-101943.txt

Regression?

No, this happened as I was adding code to a test project. Removing the new code fixes the crash.

Known Workarounds

No

Configuration
$ dotnet --info
.NET SDK:
 Version:           9.0.103
 Commit:            049799c39d
 Workload version:  9.0.101.2
 MSBuild version:   17.12.21+f7f4b086d

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  14.7
 OS Platform: Darwin
 RID:         osx-arm64
 Base Path:   /usr/local/share/dotnet/sdk/9.0.103/

.NET workloads installed:
 [macos]
   Installation Source: SDK 9.0.100
   Manifest Version:    15.2.9170/9.0.100
   Manifest Path:       /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.sdk.macos/15.2.9170/WorkloadManifest.json
   Install Type:        FileBased

 [maui-ios]
   Installation Source: SDK 9.0.100
   Manifest Version:    9.0.0/9.0.100
   Manifest Path:       /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.sdk.maui/9.0.0/WorkloadManifest.json
   Install Type:        FileBased

 [ios]
   Installation Source: SDK 9.0.100
   Manifest Version:    18.2.9170/9.0.100
   Manifest Path:       /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.sdk.ios/18.2.9170/WorkloadManifest.json
   Install Type:        FileBased

 [maccatalyst]
   Installation Source: SDK 9.0.100
   Manifest Version:    18.2.9170/9.0.100
   Manifest Path:       /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.sdk.maccatalyst/18.2.9170/WorkloadManifest.json
   Install Type:        FileBased

 [maui]
   Installation Source: SDK 9.0.100
   Manifest Version:    9.0.0/9.0.100
   Manifest Path:       /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.sdk.maui/9.0.0/WorkloadManifest.json
   Install Type:        FileBased

 [tvos]
   Installation Source: SDK 9.0.100
   Manifest Version:    18.2.9170/9.0.100
   Manifest Path:       /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.sdk.tvos/18.2.9170/WorkloadManifest.json
   Install Type:        FileBased

 [android]
   Installation Source: SDK 9.0.100
   Manifest Version:    35.0.24/9.0.100
   Manifest Path:       /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.sdk.android/35.0.24/WorkloadManifest.json
   Install Type:        FileBased

Configured to use workload sets when installing new manifests.

Host:
  Version:      9.0.1
  Architecture: arm64
  Commit:       c8acea2262

.NET SDKs installed:
  7.0.410 [/usr/local/share/dotnet/sdk]
  8.0.304 [/usr/local/share/dotnet/sdk]
  8.0.402 [/usr/local/share/dotnet/sdk]
  9.0.100 [/usr/local/share/dotnet/sdk]
  9.0.102 [/usr/local/share/dotnet/sdk]
  9.0.103 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 7.0.20 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0-rc.2.24474.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.36 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.20 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  /Users/rolf/work/dotnet/macios/main/macios/global.json

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
Other information

No response

Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/runtime

All issues in dotnet/runtime

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.