Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NativeAOT] osx-arm64 build error: compact unwind compressed function offset doesn't fit in 24 bits #93044

Closed
neon-sunset opened this issue Oct 5, 2023 · 9 comments

Comments

@neon-sunset
Copy link
Contributor

neon-sunset commented Oct 5, 2023

Description

Lately, BenchmarkDotNet NativeAOT proxy project builds have started failing with the following error:
ld: Assertion failed: (false && "compact unwind compressed function offset doesn't fit in 24 bits"), function operator(), file Layout.cpp, line 5758. clang: error: linker command failed with exit code 1 (use -v to see invocation).

I have looked through similar issues but they all seem to be describing runtime issues rather than build time, hence submitting this one.

Reproduction Steps

  1. git clone --recurse-submodules https://github.com/neon-sunset/warpskimmer
  2. cd warpskimmer/bench
  3. echo 1 | dotnet run -c release --runtimes nativeaot8.0
  4. Wait for the build to finish and observe the error

Expected behavior

Benchmark runs successfully

Actual behavior

Benchmark proxy project build fails with

  0  0x104f9b648  __assert_rtn + 72
  1  0x104f560f0  ___Z13dispatchApplyIRKmZ15dispatchForEachIKN6mach_o13CompactUnwind11Diff24FixupEZNK2ld16LayoutExecutable18writeCompactUnwindENSt3__14spanIhLm18446744073709551615EEEyRKNS7_13SectionLayoutEE4$_26EvNSA_IT_Lm18446744073709551615EEEmT0_EUlmE_EvOSG_SI__block_invoke + 0
  2  0x1904dd950  _dispatch_client_callout2 + 20
  3  0x1904f0ba0  _dispatch_apply_invoke + 176
  4  0x1904dd910  _dispatch_client_callout + 20
  5  0x1904ef3cc  _dispatch_root_queue_drain + 864
  6  0x1904efa04  _dispatch_worker_thread2 + 156
  7  0x1906870d8  _pthread_wqthread + 228
  ld: Assertion failed: (false && "compact unwind compressed function offset doesn't fit in 24 bits"), function operator(), file Layout.cpp, line 5758.
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
/Users/redacted/.nuget/packages/microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/build/Microsoft.NETCore.Native.targets(364,5): error MSB3073: The command ""clang" "obj/Release/net8.0/osx-arm64/native/bb0a0e6f-26a5-46d0-9f6f-b7543b9e8d1e.o" -o "bin/Release/net8.0/osx-arm64/native/bb0a0e6f-26a5-46d0-9f6f-b7543b9e8d1e" -exported_symbols_list /dev/null -gz=zlib /Users/redacted/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/sdk/libbootstrapper.o /Users/redacted/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/sdk/libRuntime.WorkstationGC.a /Users/redacted/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/sdk/libeventpipe-disabled.a /Users/redacted/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/sdk/libstdc++compat.a /Users/redacted/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/framework/libSystem.Native.a /Users/redacted/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/framework/libSystem.Globalization.Native.a /Users/redacted/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/framework/libSystem.IO.Compression.Native.a /Users/redacted/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/framework/libSystem.Net.Security.Native.a /Users/redacted/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/framework/libSystem.Security.Cryptography.Native.Apple.a /Users/redacted/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/framework/libSystem.Security.Cryptography.Native.OpenSsl.a -g -Wl,-rpath,'@executable_path' -ldl -lobjc -lswiftCore -lswiftFoundation -lz -licucore -lm -L/usr/lib/swift -Wl,-segprot,__THUNKS,rx,rx -framework CoreFoundation -framework CryptoKit -framework Foundation -framework Security -framework GSS" exited with code 1. [/Users/redacted/Code/GitHub/warpskimmer/bench/bin/release/net8.0/bb0a0e6f-26a5-46d0-9f6f-b7543b9e8d1e/BenchmarkDotNet.Autogenerated.csproj]

Regression?

No response

Known Workarounds

No response

Configuration

macOS 14.0 23A344 arm64
Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: arm64-apple-darwin23.0.0
$ ld -version_info
{
	"version": "1015.7",
	...
	"lto": {
		"runtime_api_version": 29,
		"static_api_version": 29,
		"version_string": "LLVM version 15.0.0"
	},
	"tapi": {
		"version": "15.0.0",
		"version_string": "Apple TAPI version 15.0.0 (tapi-1500.0.12.3)"
	}
}
.NET SDK:
 Version:           8.0.100-rtm.23504.11
 Commit:            44e6cb59e0
 Workload version:  8.0.100-manifests.62c21d7e

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  14.0
 OS Platform: Darwin
 RID:         osx-arm64
 Base Path:   /usr/local/share/dotnet/sdk/8.0.100-rtm.23504.11/

.NET workloads installed:
 Workload version: 8.0.100-manifests.62c21d7e
There are no installed workloads to display.

Host:
  Version:      8.0.0-rtm.23503.15
  Architecture: arm64
  Commit:       a84f8ffbf5

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Oct 5, 2023
@ghost
Copy link

ghost commented Oct 5, 2023

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Lately, BenchmarkDotNet NativeAOT proxy project builds have started failing with the following error:
ld: Assertion failed: (false && "compact unwind compressed function offset doesn't fit in 24 bits"), function operator(), file Layout.cpp, line 5758. clang: error: linker command failed with exit code 1 (use -v to see invocation).

I have looked through similar issues but they all seem to be describing runtime issues rather than build time, hence submitting this one.

Reproduction Steps

  1. git clone --recurse-submodules https://github.com/neon-sunset/warpskimmer
  2. cd bench && dotnet run -c release --runtimes nativeaot8.0
  3. Select any benchmark
  4. Wait for the build to finish and observe the error

Expected behavior

Benchmark runs successfully

Actual behavior

Benchmark proxy project build fails with

  0  0x104f9b648  __assert_rtn + 72
  1  0x104f560f0  ___Z13dispatchApplyIRKmZ15dispatchForEachIKN6mach_o13CompactUnwind11Diff24FixupEZNK2ld16LayoutExecutable18writeCompactUnwindENSt3__14spanIhLm18446744073709551615EEEyRKNS7_13SectionLayoutEE4$_26EvNSA_IT_Lm18446744073709551615EEEmT0_EUlmE_EvOSG_SI__block_invoke + 0
  2  0x1904dd950  _dispatch_client_callout2 + 20
  3  0x1904f0ba0  _dispatch_apply_invoke + 176
  4  0x1904dd910  _dispatch_client_callout + 20
  5  0x1904ef3cc  _dispatch_root_queue_drain + 864
  6  0x1904efa04  _dispatch_worker_thread2 + 156
  7  0x1906870d8  _pthread_wqthread + 228
  ld: Assertion failed: (false && "compact unwind compressed function offset doesn't fit in 24 bits"), function operator(), file Layout.cpp, line 5758.
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
/Users/redacted/.nuget/packages/microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/build/Microsoft.NETCore.Native.targets(364,5): error MSB3073: The command ""clang" "obj/Release/net8.0/osx-arm64/native/bb0a0e6f-26a5-46d0-9f6f-b7543b9e8d1e.o" -o "bin/Release/net8.0/osx-arm64/native/bb0a0e6f-26a5-46d0-9f6f-b7543b9e8d1e" -exported_symbols_list /dev/null -gz=zlib /Users/redacted/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/sdk/libbootstrapper.o /Users/redacted/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/sdk/libRuntime.WorkstationGC.a /Users/redacted/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/sdk/libeventpipe-disabled.a /Users/redacted/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/sdk/libstdc++compat.a /Users/redacted/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/framework/libSystem.Native.a /Users/redacted/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/framework/libSystem.Globalization.Native.a /Users/redacted/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/framework/libSystem.IO.Compression.Native.a /Users/redacted/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/framework/libSystem.Net.Security.Native.a /Users/redacted/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/framework/libSystem.Security.Cryptography.Native.Apple.a /Users/redacted/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0-rtm.23503.15/framework/libSystem.Security.Cryptography.Native.OpenSsl.a -g -Wl,-rpath,'@executable_path' -ldl -lobjc -lswiftCore -lswiftFoundation -lz -licucore -lm -L/usr/lib/swift -Wl,-segprot,__THUNKS,rx,rx -framework CoreFoundation -framework CryptoKit -framework Foundation -framework Security -framework GSS" exited with code 1. [/Users/redacted/Code/GitHub/warpskimmer/bench/bin/release/net8.0/bb0a0e6f-26a5-46d0-9f6f-b7543b9e8d1e/BenchmarkDotNet.Autogenerated.csproj]

Regression?

No response

Known Workarounds

No response

Configuration

macOS 14.0 23A344 arm64
Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: arm64-apple-darwin23.0.0
$ ld -version_info
{
	"version": "1015.7",
	...
	"lto": {
		"runtime_api_version": 29,
		"static_api_version": 29,
		"version_string": "LLVM version 15.0.0"
	},
	"tapi": {
		"version": "15.0.0",
		"version_string": "Apple TAPI version 15.0.0 (tapi-1500.0.12.3)"
	}
}
.NET SDK:
 Version:           8.0.100-rtm.23504.11
 Commit:            44e6cb59e0
 Workload version:  8.0.100-manifests.62c21d7e

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  14.0
 OS Platform: Darwin
 RID:         osx-arm64
 Base Path:   /usr/local/share/dotnet/sdk/8.0.100-rtm.23504.11/

.NET workloads installed:
 Workload version: 8.0.100-manifests.62c21d7e
There are no installed workloads to display.

Host:
  Version:      8.0.0-rtm.23503.15
  Architecture: arm64
  Commit:       a84f8ffbf5

Other information

No response

Author: neon-sunset
Assignees: -
Labels:

untriaged, area-NativeAOT-coreclr

Milestone: -

@jkotas
Copy link
Member

jkotas commented Oct 5, 2023

@filipnavara Could you please take a look?

@filipnavara
Copy link
Member

I wonder if this is just another instance of #88292 and Apple's new linker just asserts on it instead of producing garbage. The version information seems to imply that Xcode 15 is used.

@filipnavara
Copy link
Member

@neon-sunset Would it be possible to dump the section sizes of the .o file from NativeAOT output with objdump -h?

@MichalStrehovsky MichalStrehovsky added the os-mac-os-x macOS aka OSX label Oct 5, 2023
@neon-sunset
Copy link
Contributor Author

neon-sunset commented Oct 5, 2023

@filipnavara please let me know if you need any other information

❯ objdump -h bb0a0e6f-26a5-46d0-9f6f-b7543b9e8d1e.o                                                    (base)

bb0a0e6f-26a5-46d0-9f6f-b7543b9e8d1e.o:	file format mach-o arm64

Sections:
Idx Name             Size     VMA              Type
  0 __text           00039e9c 0000000000000000 TEXT
  1 __managedcode    018cc758 0000000000039ea0 TEXT
  2 .dotnet_eh_table 00317aca 00000000019065f8 DATA
  3 __const          01a278af 0000000001c1e0c8 DATA
  4 __data           000d3458 0000000003645978 DATA
  5 hydrated         00d1dd78 0000000008f400a0 BSS
  6 __unbox          0000b0d0 0000000003718dd0 TEXT
  7 __modules        00000008 0000000003723ea0 DATA
  8 __bss            000a6308 0000000009c5de18 BSS
  9 __debug_str      0325ef85 0000000003723ea8 DATA, DEBUG
 10 __debug_info     00e1fed1 0000000006982e2d DATA, DEBUG
 11 __debug_abbrev   000001cf 00000000077a2cfe DATA, DEBUG
 12 __debug_aranges  00000030 00000000077a2ecd DATA, DEBUG
 13 __debug_loc      00b1b058 00000000077a2efd DATA, DEBUG
 14 __compact_unwind 004f47a0 00000000082bdf58 DATA
 15 __eh_frame       005cac90 00000000087b26f8 DATA
 16 __debug_line     001c2d13 0000000008d7d388 DATA, DEBUG

@filipnavara
Copy link
Member

Thanks! The size of the data in __eh_frame section in this case seems to be below the problematic limit. I'll need to dig deeper to find out what is the new Apple linker screwing up this time. I also need to check that the 8.0.100-rtm.23504.11 SDK build already has all the Xcode 15 fixes.

Meanwhile, the only thing I can offer is a workaround to force the old ld64 linker through .csproj property:

<ItemGroup>
  <LinkerArg Include="-Wl,-ld_classic" />
</ItemGroup>

@ErisApps
Copy link

ErisApps commented Dec 1, 2023

Thanks! The size of the data in __eh_frame section in this case seems to be below the problematic limit. I'll need to dig deeper to find out what is the new Apple linker screwing up this time. I also need to check that the 8.0.100-rtm.23504.11 SDK build already has all the Xcode 15 fixes.

Meanwhile, the only thing I can offer is a workaround to force the old ld64 linker through .csproj property:

<ItemGroup>
  <LinkerArg Include="-Wl,-ld_classic" />
</ItemGroup>

Hii,

I'm stumbling upon the same issue using stable .NET 8 (8.0.100) in the context of BenchmarkDotNet. However, I can't seem to get the workaround using the LinkerArg property working for the benchmark project. Not sure whether it's an issue with BenchmarkDotNet not picking up the property or whether the workaround itself is not fully addressing the issue at hand.

@am11
Copy link
Member

am11 commented Jan 11, 2024

I can reproduce the issue with net8.0, but it seems to be fixed in 9.0.100-alpha.1.24061.4 daily build.

On osx-arm64 with Xcode 15.1: run curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --quality daily --channel "9.0" --install-dir "~/.dotnet9", create alias dotnet9=~/.dotnet9/dotnet, update TargetFramework to net9.0 in warpskimmer/bench/Warpskimmer.Benchmark.csproj and start the tests with echo 1 | dotnet9 run -c release --runtimes nativeaot9.0 --cli ~/.dotnet9/dotnet. No errors.

I haven't bisected which commit fixed it, so we can ask for the backport. @filipnavara, do you have an idea? (It passes both with and without setting DOTNET_USE_LLVM_OBJWRITER=1 using net9.0 daily build)

@agocke
Copy link
Member

agocke commented Apr 19, 2024

I think this is resolved since we've switch to the old linker by default.

@agocke agocke closed this as completed Apr 19, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Apr 19, 2024
@github-actions github-actions bot locked and limited conversation to collaborators May 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

No branches or pull requests

7 participants