dotnet / runtime

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

Publish single file blazer server for osx-arm64 executable segfaults #70588

Closed mockjv closed 2 years ago

mockjv commented 2 years ago

Description

Attempting to produce a single file executable targeting osx-arm64 that happens to be based on the Blazor Server template produces a bootstrap/host-executable that segfaults. I don't experience this is with published apps targeting osx-x64. I also don't experience this issue with at least the console template.

Reproduction Steps

Using .NET 6.0.300 SDK

❯ mkdir blazorSingleFileTest
❯ cd blazorSingleFileTest
❯ dotnet new blazorserver
The template "Blazor Server App" was created successfully.
This template contains technologies from parties other than Microsoft, see https://aka.ms/aspnetcore/6.0-third-party-notices for details.

Processing post-creation actions...
Running 'dotnet restore' on /Users/E4226/Development/blazorSingleFileTest/blazorSingleFileTest.csproj...
  Determining projects to restore...
  Restored /Users/E4226/Development/blazorSingleFileTest/blazorSingleFileTest.csproj (in 42 ms).
Restore succeeded.

❯ dotnet publish -r osx-arm64 --self-contained /p:PublishSingleFile=true
Microsoft (R) Build Engine version 17.2.0+41abc5629 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored /Users/E4226/Development/blazorSingleFileTest/blazorSingleFileTest.csproj (in 86 ms).
  blazorSingleFileTest -> /Users/E4226/Development/blazorSingleFileTest/bin/Debug/net6.0/osx-arm64/blazorSingleFileTest.dll
  blazorSingleFileTest -> /Users/E4226/Development/blazorSingleFileTest/bin/Debug/net6.0/osx-arm64/publish/
❯ cd bin/Debug/net6.0/osx-arm64/publish/
❯ ./blazorSingleFileTest
[1]    90350 segmentation fault  ./blazorSingleFileTest

Expected behavior

Not crash! 😀

Actual behavior

The produced executable file segfaults:

[1]    90350 segmentation fault  ./blazorSingleFileTest

Regression?

Haven't expressly tried this with any prior versions so unsure if this is a regression.

Known Workarounds

None

Configuration

.NET SDK 6.0.300

MacOS 12.4

M1 MacBook Pro

Other information

No response

ghost commented 2 years ago

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

Issue Details
### Description Attempting to produce a single file executable targeting `osx-arm64` that happens to be based on the Blazor Server template produces a bootstrap/host-executable that segfaults. I don't experience this is with published apps targeting `osx-x64`. I also don't experience this issue with at least the `console` template. ### Reproduction Steps Using .NET 6.0.300 SDK ```shell ❯ mkdir blazorSingleFileTest ❯ cd blazorSingleFileTest ❯ dotnet new blazorserver The template "Blazor Server App" was created successfully. This template contains technologies from parties other than Microsoft, see https://aka.ms/aspnetcore/6.0-third-party-notices for details. Processing post-creation actions... Running 'dotnet restore' on /Users/E4226/Development/blazorSingleFileTest/blazorSingleFileTest.csproj... Determining projects to restore... Restored /Users/E4226/Development/blazorSingleFileTest/blazorSingleFileTest.csproj (in 42 ms). Restore succeeded. ❯ dotnet publish -r osx-arm64 --self-contained /p:PublishSingleFile=true Microsoft (R) Build Engine version 17.2.0+41abc5629 for .NET Copyright (C) Microsoft Corporation. All rights reserved. Determining projects to restore... Restored /Users/E4226/Development/blazorSingleFileTest/blazorSingleFileTest.csproj (in 86 ms). blazorSingleFileTest -> /Users/E4226/Development/blazorSingleFileTest/bin/Debug/net6.0/osx-arm64/blazorSingleFileTest.dll blazorSingleFileTest -> /Users/E4226/Development/blazorSingleFileTest/bin/Debug/net6.0/osx-arm64/publish/ ❯ cd bin/Debug/net6.0/osx-arm64/publish/ ❯ ./blazorSingleFileTest [1] 90350 segmentation fault ./blazorSingleFileTest ``` ### Expected behavior Not crash! 😀 ### Actual behavior The produced executable file segfaults: ```shell [1] 90350 segmentation fault ./blazorSingleFileTest ``` ### Regression? Haven't expressly tried this with any prior versions so unsure if this is a regression. ### Known Workarounds None ### Configuration .NET SDK 6.0.300 MacOS 12.4 M1 MacBook Pro ### Other information _No response_
Author: mockjv
Assignees: -
Labels: `area-Single-File`, `untriaged`
Milestone: -
agocke commented 2 years ago

@VSadov can you take a look? Would this be fixed by the recent change we took?

VSadov commented 2 years ago

The symptoms look a lot like the issues that were just fixed.

I am not sure if we have any SDK builds published with the fixes yet. It generally takes a few days to got to SDK repo. Maybe next week. Then it would be possible to try the same scenario with pre-release SDK - to see if this is fixed.

VSadov commented 2 years ago

One thing can be tried is to run the app with R2R disabled -

export COMPlus_ZapDisable=1

If it still crashes, then it could be something else.

mockjv commented 2 years ago

@VSadov Sure enough that fixed my issue!

mockjv commented 2 years ago

@VSadov Once have a moment to test the latest SDK, I'd be glad to close this but based on your description it's sounding like that'll be the case.

mockjv commented 2 years ago

So, technically I get a different error message (bus error as opposed to a segmentation fault), but still experiencing a crash with 6.0.301. More of an FYI, as I assume that means that the changes didn't make their way into the recent release.

❯ cd /Users/E4226/Development/m1Test/bin/Debug/net6.0/osx-arm64/publish/
❯ dotnet publish -r osx-arm64 --self-contained /p:PublishSingleFile=true
Microsoft (R) Build Engine version 17.2.0+41abc5629 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored /Users/E4226/Development/m1Test/m1Test.csproj (in 5.97 sec).
  m1Test -> /Users/E4226/Development/m1Test/bin/Debug/net6.0/osx-arm64/m1Test.dll
  m1Test -> /Users/E4226/Development/m1Test/bin/Debug/net6.0/osx-arm64/publish/
❯ cd /Users/E4226/Development/m1Test/bin/Debug/net6.0/osx-arm64/publish/
❯ ./m1Test
[1]    3725 bus error  ./m1Test
❯ export COMPlus_ZapDisable=1
❯ ./m1Test
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: https://localhost:5001
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /Users/E4226/Development/m1Test/bin/Debug/net6.0/osx-arm64/publish/
agocke commented 2 years ago

@mockjv Is this still occuring in 3.0.302/6.0.7?

mockjv commented 2 years ago

@agocke Thanks for the reminder, looking good with 6.0.302/6.0.7 so closing...