dotnet / runtime

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

SingleFile asp.net apps throw an exception #54759

Closed mangod9 closed 2 years ago

mangod9 commented 3 years ago

Description

Asp.net singleFile apps throw the following exception:

[STDERR] Unhandled exception. System.DllNotFoundException: Unable to load shared library 'libSystem.Native' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibSystem.Native: cannot open shared object file: No such file or directory
[STDERR]    at System.Runtime.InteropServices.Marshal.AllocBSTRByteLen(UInt32 length) in System.Private.CoreLib.dll:token 0x600463f+0x1d
[STDERR]    at System.StubHelpers.AnsiBSTRMarshaler.ConvertToNative(Int32 flags, String strManaged) in System.Private.CoreLib.dll:token 0x6003357+0x2f
[STDERR]    at Interop.Globalization.GetSortHandle(String localeName, IntPtr& sortHandle) in System.Private.CoreLib.dll:token 0x600001c+0x25
[STDERR]    at System.Globalization.CompareInfo.SortHandleCache.GetCachedSortHandle(String sortName) in System.Private.CoreLib.dll:token 0x600204f+0x1f
[STDERR]    at System.Globalization.CompareInfo.IcuInitSortHandle() in System.Private.CoreLib.dll:token 0x6002033+0x77
[STDERR]    at System.Globalization.CultureInfo.get_CompareInfo() in System.Private.CoreLib.dll:token 0x6002106+0xa
[STDERR]    at System.String.StartsWith(String value, StringComparison comparisonType) in System.Private.CoreLib.dll:token 0x60006d1+0x0
[STDERR]    at System.String.StartsWith(String value) in System.Private.CoreLib.dll:token 0x60006d0+0xe
[STDERR]    at Microsoft.Extensions.Configuration.CommandLine.CommandLineConfigurationProvider.Load() in Microsoft.Extensions.Configuration.CommandLine.dll:token 0x600001c+0x27
[STDERR]    at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers) in Microsoft.Extensions.Configuration.dll:token 0x600003f+0x52
[STDERR]    at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build() in Microsoft.Extensions.Configuration.dll:token 0x6000028+0x3e
[STDERR]    at Benchmarks.Program.Main(String[] args) in Benchmarks.dll:token 0x6000032+0xfa

Configuration

1. dotnet new webapi
2. dotnet publish -r linux-x64 /p:PublishSingleFile=true

Regression?

Yes, looks related to this change: https://github.com/dotnet/runtime/pull/54006

ghost commented 3 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 Asp.net singleFile apps throw the following exception: ``` [STDERR] Unhandled exception. System.DllNotFoundException: Unable to load shared library 'libSystem.Native' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibSystem.Native: cannot open shared object file: No such file or directory [STDERR] at System.Runtime.InteropServices.Marshal.AllocBSTRByteLen(UInt32 length) in System.Private.CoreLib.dll:token 0x600463f+0x1d [STDERR] at System.StubHelpers.AnsiBSTRMarshaler.ConvertToNative(Int32 flags, String strManaged) in System.Private.CoreLib.dll:token 0x6003357+0x2f [STDERR] at Interop.Globalization.GetSortHandle(String localeName, IntPtr& sortHandle) in System.Private.CoreLib.dll:token 0x600001c+0x25 [STDERR] at System.Globalization.CompareInfo.SortHandleCache.GetCachedSortHandle(String sortName) in System.Private.CoreLib.dll:token 0x600204f+0x1f [STDERR] at System.Globalization.CompareInfo.IcuInitSortHandle() in System.Private.CoreLib.dll:token 0x6002033+0x77 [STDERR] at System.Globalization.CultureInfo.get_CompareInfo() in System.Private.CoreLib.dll:token 0x6002106+0xa [STDERR] at System.String.StartsWith(String value, StringComparison comparisonType) in System.Private.CoreLib.dll:token 0x60006d1+0x0 [STDERR] at System.String.StartsWith(String value) in System.Private.CoreLib.dll:token 0x60006d0+0xe [STDERR] at Microsoft.Extensions.Configuration.CommandLine.CommandLineConfigurationProvider.Load() in Microsoft.Extensions.Configuration.CommandLine.dll:token 0x600001c+0x27 [STDERR] at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers) in Microsoft.Extensions.Configuration.dll:token 0x600003f+0x52 [STDERR] at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build() in Microsoft.Extensions.Configuration.dll:token 0x6000028+0x3e [STDERR] at Benchmarks.Program.Main(String[] args) in Benchmarks.dll:token 0x6000032+0xfa ``` ### Configuration ``` 1. dotnet new webapi 2. dotnet publish -r lin-x64 /p:PublishSingleFile=true ``` ### Regression? Yes, looks related to this change: https://github.com/dotnet/runtime/pull/54006
Author: mangod9
Assignees: -
Labels: `area-Single-File`
Milestone: -
mangod9 commented 3 years ago

@tannergooding as fyi..

mangod9 commented 3 years ago

actually I am unable to repro with a vanilla asp.net app. @sebastienros assume this is specific to the asp.net Benchmarks infra then? Do you have the exact commandline that fails ?

sebastienros commented 3 years ago

This might be triggered by a specific call when the configuration for this app is invoked. To repro I would suggest to clone https://github.com/aspnet/Benchmarks, then build src/Benchmarks with this command line, using the latest SDK:

dotnet publish Benchmarks.csproj -c Release -o ./published /p:MicrosoftNETCoreAppPackageVersion=6.0.0-preview.7.21325.9 /p:MicrosoftAspNetCoreAppPackageVersion=6.0.0-preview.7.21325.3 /p:BenchmarksTargetFramework=net6.0 /p:PublishReadyToRun=true /p:PublishSingleFile=true --framework net6.0 --self-contained -r linux-x64 

Then the error should happen on the first request. We can also provide the self-contained published folder if someone prefers that.

Update: The ASP.NET and NetCoreApp version in this example will probably not match the ones provided by the SDK you download. Please update these version in the command lines with the ones you downloaded.

VSadov commented 3 years ago

@sebastienros I followed the steps above and I get

published$ ./Benchmarks

ASP.NET Core Benchmarks
-----------------------
Current directory: /SSD/vsadov/Benchmarks/src/Benchmarks/published
AspNetCore version: 6.0.0-preview.7.21322.5+13943a5b2e4051b0f478f59c560f197582ebcf0b
.NET Runtime version: 6.0.0-preview.7.21321.15+2a43c07bb82113a029090730d8ca001a68b22c05
EFCore version: 6.0.0-preview.4.21253.1
Environment.ProcessorCount: 8
Unhandled exception. System.InvalidOperationException: Transport must be specified
   at Benchmarks.Program.Main(String[] args) in /SSD/vsadov/Benchmarks/src/Benchmarks/Program.cs:line 163
Aborted

Not sure if this is getting further than in the original repro or fails before hitting the issue.

VSadov commented 3 years ago

This is with 6.0.100-preview.7.21323.6

mangod9 commented 3 years ago

you need to specify a transport. I cannot repro the issue with these either:

./Benchmarks --kestreltransport sockets
ASP.NET Core Benchmarks
-----------------------
Current directory: /home/magodse/p7/Benchmarks/src/published
AspNetCore version: 6.0.0-preview.7.21323.6+7b28c2b572cf32cf3c874d637ca8337a3b459830
.NET Runtime version: 6.0.0-preview.7.21324.1+7833828914a42f8c99dfa6f18ccd47f99dc2b56e
EFCore version: 6.0.0-preview.4.21253.1
Environment.ProcessorCount: 12
The following scenarios were enabled:
  Json -> /json

Database: None
WAL: False
Using server Kestrel
Server GC is currently ENABLED
Press 'C' to force GC or any other key to display GC stats

Using Sockets with 12 threads
Hosting environment: Production
Now listening on: http://127.0.0.1:5000

and used curl to send a request:

:~$ curl --get http://127.0.0.1:5000/json
{"message":"Hello, World!"}
agocke commented 3 years ago

@mangod9 Is this the same problem as was fixed in https://github.com/dotnet/runtime/pull/55032?

agocke commented 2 years ago

Assuming this was https://github.com/dotnet/runtime/pull/55032