dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.25k stars 4.73k forks source link

.NET 8.0.401 + macOS crashes, while .NET 8.0.303 doesn't. #106661

Open jonpryor opened 2 months ago

jonpryor commented 2 months ago

Description

.NET 8.0.401 + macOS crashes, while .NET 8.0.303 doesn't.

Reproduction Steps

Alas, not minimal:

# Repro is from building the dotnet/java-interop repo
git clone https://github.com/dotnet/java-interop.git
cd java-interop
git checkout fcad3368815dffd0f38f64384aa21b0b65367d68
git submodule update --init --recursive

# ensure .NET 8.0.401 is used
export PATH=$HOME/Downloads/dotnet-sdk-8.0.401-osx-x64:$PATH

# prepare
dotnet build -t:Prepare Java.Interop.sln

# build
dotnet build Java.Interop.sln

Expected behavior

Build completes without error.

Note: requires that dotnet/java-interop dependencies already exist, which includes a C++ toolchain, Java SDK, etc.…

Actual behavior

Fails to build:

tmp7adcfcd1012f44439ffd2772eea8f2e1.exec.cmd: line 2: 89333 Segmentation fault: 11  "…/dotnet-sdk-8.0.401-osx-x64/dotnet" "…/java-interop/bin/Debug-net8.0//jnimarshalmethod-gen.dll" "…/java-interop/samples/Hello-NativeAOTFromJNI/bin/Debug/Hello-NativeAOTFromJNI.dll" -v -v --keeptemp -L "…/java-interop/samples/Hello-NativeAOTFromJNI/bin/Debug/"
…/java-interop/samples/Hello-NativeAOTFromJNI/Hello-NativeAOTFromJNI.targets(44,5): error MSB3073: The command ""…/dotnet-sdk-8.0.401-osx-x64/dotnet" "…/java-interop/bin/Debug-net8.0//jnimarshalmethod-gen.dll" "…/java-interop/samples/Hello-NativeAOTFromJNI/bin/Debug/Hello-NativeAOTFromJNI.dll" -v -v --keeptemp -L "…/java-interop/samples/Hello-NativeAOTFromJNI/bin/Debug/" " exited with code 139. […/java-interop/samples/Hello-NativeAOTFromJNI/Hello-NativeAOTFromJNI.csproj]

Re-run with diagnostic logging enabled:

dotnet build -v:diag Java.Interop.sln > b.txt

and there isn't much additional output regarding the crash.

Regression?

Yes. This same repo builds with .NET 8.0.303. See also: https://github.com/dotnet/java-interop/pull/1245

Known Workarounds

Use .NET 8.0.303.

Configuration

Other information

This doesn't appear to fail on Linux-x64.

jonpryor commented 2 months ago

Note: you may need to run dotnet build Java.Inteorp.sln more than once to get to the crash. I've also seen this error, which doesn't repro:

…/dotnet-sdk-8.0.401-osx-x64/sdk/8.0.401/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(379,5): error MSB4018: The "GenerateRuntimeConfigurationFiles" task failed unexpectedly. […/java-interop/build-tools/jnienv-gen/jnienv-gen.csproj]
…/dotnet-sdk-8.0.401-osx-x64/sdk/8.0.401/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(379,5): error MSB4018: System.IO.IOException: The process cannot access the file '…/java-interop/bin/BuildDebug-net8.0/jnienv-gen.runtimeconfig.json' because it is being used by another process. […/java-interop/build-tools/jnienv-gen/jnienv-gen.csproj]
…/dotnet-sdk-8.0.401-osx-x64/sdk/8.0.401/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(379,5): error MSB4018:    at Microsoft.Win32.SafeHandles.SafeFileHandle.Init(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Int64& fileLength, UnixFileMode& filePermissions) […/java-interop/build-tools/jnienv-gen/jnienv-gen.csproj]
…/dotnet-sdk-8.0.401-osx-x64/sdk/8.0.401/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(379,5): error MSB4018:    at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException) […/java-interop/build-tools/jnienv-gen/jnienv-gen.csproj]
…/dotnet-sdk-8.0.401-osx-x64/sdk/8.0.401/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(379,5): error MSB4018:    at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode) […/java-interop/build-tools/jnienv-gen/jnienv-gen.csproj]
…/dotnet-sdk-8.0.401-osx-x64/sdk/8.0.401/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(379,5): error MSB4018:    at System.IO.File.Create(String path) […/java-interop/build-tools/jnienv-gen/jnienv-gen.csproj]
…/dotnet-sdk-8.0.401-osx-x64/sdk/8.0.401/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(379,5): error MSB4018:    at Microsoft.NET.Build.Tasks.GenerateRuntimeConfigurationFiles.WriteToJsonFile(String fileName, Object value) […/java-interop/build-tools/jnienv-gen/jnienv-gen.csproj]
…/dotnet-sdk-8.0.401-osx-x64/sdk/8.0.401/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(379,5): error MSB4018:    at Microsoft.NET.Build.Tasks.GenerateRuntimeConfigurationFiles.WriteRuntimeConfig(RuntimeFramework[] runtimeFrameworks, LockFileTargetLibrary platformLibrary, Boolean isFrameworkDependent, IList`1 packageFolders) […/java-interop/build-tools/jnienv-gen/jnienv-gen.csproj]
…/dotnet-sdk-8.0.401-osx-x64/sdk/8.0.401/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(379,5): error MSB4018:    at Microsoft.NET.Build.Tasks.GenerateRuntimeConfigurationFiles.ExecuteCore() […/java-interop/build-tools/jnienv-gen/jnienv-gen.csproj]
…/dotnet-sdk-8.0.401-osx-x64/sdk/8.0.401/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(379,5): error MSB4018:    at Microsoft.NET.Build.Tasks.TaskBase.Execute() […/java-interop/build-tools/jnienv-gen/jnienv-gen.csproj]
…/dotnet-sdk-8.0.401-osx-x64/sdk/8.0.401/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(379,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Execute() […/java-interop/build-tools/jnienv-gen/jnienv-gen.csproj]
…/dotnet-sdk-8.0.401-osx-x64/sdk/8.0.401/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(379,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(TaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) […/java-interop/build-tools/jnienv-gen/jnienv-gen.csproj]

I'm not (currently) reporting this MSB4018 from GenerateRuntimeConfigurationFiles.

agocke commented 1 month ago

@AaronRobinsonMSFT Did we make any servicing fixes that could have caused this?

jkotas commented 1 month ago

This might have been introduced by https://github.com/dotnet/runtime/pull/104818 and fixed by https://github.com/dotnet/runtime/pull/107199 .

cc @janvorli

janvorli commented 1 month ago

If the crash occurs only under Rosetta and not on a real x64 macOS and there is some hardware exception handling going on, this could be what @jkotas said.

jonpryor commented 2 days ago

@janvorli wrote:

If the crash occurs only under Rosetta and not on a real x64 macOS … this could be what @jkotas said.

I was experiencing this on an x64 macOS machine. No arm64, no Rosetta.