Runtime: mac:dotnet new FailFast (ja_JP.UTF-8)

Created on 22 Jun 2018  ·  26Comments  ·  Source: dotnet/runtime

I have an error below, when I run "dotnet new --all" command after installed a pkg of "dotnet-sdk-2.1.300-osx-x64.pkg" on macOS High Sierra v10.13.5.

FailFast:
Infinite recursion during resource lookup within System.Private.CoreLib. This may be a bug in System.Private.CoreLib, or potentially in certain extensibility points such as assembly resolve events or CultureInfo names. Resource name: Argument_InvalidResourceCultureName

at System.Environment.FailFast(System.String)
at System.SR.InternalGetResourceString(System.String)
at System.SR.GetResourceString(System.String, System.String)
at System.Globalization.CultureInfo.VerifyCultureName(System.String, Boolean)
at System.Resources.ResourceManager.GetResourceFileName(System.Globalization.CultureInfo)
at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(System.Globalization.CultureInfo, System.Collections.Generic.Dictionary2<System.String,System.Resources.ResourceSet>, Boolean, Boolean, System.Threading.StackCrawlMark ByRef) at System.Resources.ResourceManager.InternalGetResourceSet(System.Globalization.CultureInfo, Boolean, Boolean, System.Threading.StackCrawlMark ByRef) at System.Resources.ResourceManager.InternalGetResourceSet(System.Globalization.CultureInfo, Boolean, Boolean) at System.Resources.ResourceManager.GetString(System.String, System.Globalization.CultureInfo) at System.SR.InternalGetResourceString(System.String) at System.SR.GetResourceString(System.String, System.String) at System.Globalization.CultureInfo.VerifyCultureName(System.String, Boolean) at System.Resources.ResourceManager.GetResourceFileName(System.Globalization.CultureInfo) at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(System.Globalization.CultureInfo, System.Collections.Generic.Dictionary2, Boolean, Boolean, System.Threading.StackCrawlMark ByRef)
at System.Resources.ResourceManager.InternalGetResourceSet(System.Globalization.CultureInfo, Boolean, Boolean, System.Threading.StackCrawlMark ByRef)
at System.Resources.ResourceManager.InternalGetResourceSet(System.Globalization.CultureInfo, Boolean, Boolean)
at System.Resources.ResourceManager.GetString(System.String, System.Globalization.CultureInfo)
at System.SR.InternalGetResourceString(System.String)
at System.SR.GetResourceString(System.String, System.String)
at Interop.GetExceptionForIoErrno(ErrorInfo, System.String, Boolean)
at Interop.ThrowExceptionForIoErrno(ErrorInfo, System.String, Boolean, System.Func`2)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(System.String, OpenFlags, Int32)
at System.IO.FileStream..ctor(System.String, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, Int32, System.IO.FileOptions)
at Microsoft.Extensions.EnvironmentAbstractions.FileWrapper.OpenFile(System.String, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, Int32, System.IO.FileOptions)
at Microsoft.DotNet.Configurer.NuGetCacheSentinel.SetInProgressSentinel()
at Microsoft.DotNet.Configurer.NuGetCacheSentinel..ctor(Microsoft.DotNet.Configurer.CliFolderPathCalculator)
at Microsoft.DotNet.Cli.Program.ProcessArgs(System.String[], Microsoft.DotNet.Cli.Telemetry.ITelemetry)
at Microsoft.DotNet.Cli.Program.Main(System.String[])
Abort trap: 6

area-System.Globalization bug

Most helpful comment

Hi jkotas,

Thank you for your super support.
My Lang is jp.UTF-8 and LC_ALL is blank. below is result.
$ echo $LANG
LANG=ja_JP.UTF-8

$ echo $LC_ALL
(Blank)

I set export LANG=en_US.UTF-8 and export LANG=en_US.UTF-8, and then run "dotnet new --all" command.

It's working!! and actually I was able to run "dotnet new -i Amazon.Lambda.Templates::*" without any errors.

Thanks again!
Awesome!

$ dotnet new --all

Welcome to .NET Core!

Learn more about .NET Core: https://aka.ms/dotnet-docs
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs

Telemetry

The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous and doesn't include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

ASP.NET Core

Successfully installed the ASP.NET Core HTTPS Development Certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only). For establishing trust on other platforms refer to the platform specific documentation.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
Invalid input switch:
--all
Run dotnet new --help for usage information.
See https://aka.ms/dotnet-install-templates to learn how to install additional template packs.
$

All 26 comments

Can anyone solve this issue? Please help.

Could you please tell us what your LANG and LC_ALL environment variables are set to?

echo $LANG
echo $LC_ALL

Could you please try setting them to en_US.UTF-8 and see whether it fixes the problem?

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

Hi jkotas,

Thank you for your super support.
My Lang is jp.UTF-8 and LC_ALL is blank. below is result.
$ echo $LANG
LANG=ja_JP.UTF-8

$ echo $LC_ALL
(Blank)

I set export LANG=en_US.UTF-8 and export LANG=en_US.UTF-8, and then run "dotnet new --all" command.

It's working!! and actually I was able to run "dotnet new -i Amazon.Lambda.Templates::*" without any errors.

Thanks again!
Awesome!

$ dotnet new --all

Welcome to .NET Core!

Learn more about .NET Core: https://aka.ms/dotnet-docs
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs

Telemetry

The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous and doesn't include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

ASP.NET Core

Successfully installed the ASP.NET Core HTTPS Development Certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only). For establishing trust on other platforms refer to the platform specific documentation.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
Invalid input switch:
--all
Run dotnet new --help for usage information.
See https://aka.ms/dotnet-install-templates to learn how to install additional template packs.
$

Good to hear that setting these environment variables worked around the issue. I am keeping the issue open. There is a bug somewhere - it should work out of the box without the workaround.

cc @krwq @tarekgh

Thanks, Jan!

The check in VerifyCultureName is very simple, it would be interesting to know what the culture is htat it is failing on.

I have tried this with botnet 2.1.301 and I cannot repro it.

➜  Test dotnet new --all    
無効な入力スイッチ:
  --all
使用方法の情報を確認するには、dotnet new --help を実行します。
その他のテンプレート パックのインストール方法については、https://aka.ms/dotnet-install-templates をご覧ください。

@tanagoa looks your machine has more specific configuration.

could you please try to revert setting the LANG environment variable back and repro the issue, then try to create a small console app and then print the values of:

CultureInfo.CurrentCulture and CultureInfo.CurrentUICulture?

@tanagoa would be nice if you try to install the latest net core 2.1.301 too.

@tanagoa could you please respond to my last comments? We need some help with what configuration you have may caused such issue.

Thanks, tarekgh

I installed below 301 pkg.
dotnet-sdk-2.1.301-osx-gs-x64.pkg

I have set below in my .bash_profile.
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

$ printenv
TERM_PROGRAM=Apple_Terminal
SHELL=/bin/bash
TERM=xterm-256color
TMPDIR=/var/folders/52/r2k65zwn5l3_xvzjjnn3d2kr0000gn/T/
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.zMGKX9ZjsW/Render
TERM_PROGRAM_VERSION=404
TERM_SESSION_ID=BE53C683-58B1-4822-9A8E-29E736815CD4
LC_ALL=en_US.UTF-8
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.xqOGkWy2eR/Listeners
LANG=en_US.UTF-8
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
SHLVL=1
LC_CTYPE=UTF-8
_=/usr/bin/printenv

Thanks @tanagoa

Are you able to repro the original problem when doing the following?

export LANG=ja_JP.UTF-8
export LC_ALL=ja_JP.UTF-8

Hi tarekgh,

I tried below, I think it's working without any errors.

$ export LANG=ja_JP.UTF-8
$ export LC_ALL=ja_JP.UTF-8
$ dotnet new -i Amazon.Lambda.Templates::*
/Users/xxx/.templateengine/dotnetcli/v2.1.301/scratch/restore.csproj のパッケージを復元しています...
Amazon.Lambda.Templates 3.0.0 をインストールしています。
MSBuild ファイル /Users/xxx/.templateengine/dotnetcli/v2.1.301/scratch/obj/restore.csproj.nuget.g.props を生成しています。
MSBuild ファイル /Users/xxx/.templateengine/dotnetcli/v2.1.301/scratch/obj/restore.csproj.nuget.g.targets を生成しています。
/Users/xxx/.templateengine/dotnetcli/v2.1.301/scratch/restore.csproj の復元が 3.74 sec で完了しました。

使用法: new [options]

オプション:
-h, --help このコマンドのヘルプを表示します。
-l, --list 指定された名前を含むテンプレートを一覧表示します。名前を指定しない場合は、すべてのテンプレートが一覧表示されます。
-n, --name 作成する出力の名前。名前を指定しない場合は、現在のディレクトリの名前が使用されます。
-o, --output 生成する出力を配置する場所。
-i, --install ソースまたはテンプレート パックをインストールします。
-u, --uninstall ソースまたはテンプレート パックをアンインストールします。
--nuget-source インストール中に使用する NuGet ソースを 1 つ指定します。
--type 使用可能な種類に基づいてテンプレートをフィルター処理します。定義済みの値は、"project"、"item"、"other" です。
--force 既存のファイルが変更されるとしても、強制的にコンテンツを生成します。
-lang, --language 言語に基づいてテンプレートをフィルター処理し、作成するテンプレートの言語を指定します。

テンプレート 短い名前 言語 タグ

Order Flowers Chatbot Tutorial lambda.OrderFlowersChatbot [C#] AWS/Lambda/Function
Lambda Detect Image Labels lambda.DetectImageLabels [C#], F# AWS/Lambda/Function
Lambda Empty Function lambda.EmptyFunction [C#], F# AWS/Lambda/Function
Lex Book Trip Sample lambda.LexBookTripSample [C#] AWS/Lambda/Function
Lambda Simple DynamoDB Function lambda.DynamoDB [C#], F# AWS/Lambda/Function
Lambda Simple Kinesis Firehose Function lambda.KinesisFirehose [C#] AWS/Lambda/Function
Lambda Simple Kinesis Function lambda.Kinesis [C#], F# AWS/Lambda/Function
Lambda Simple S3 Function lambda.S3 [C#], F# AWS/Lambda/Function
Lambda ASP.NET Core Web API serverless.AspNetCoreWebAPI [C#], F# AWS/Lambda/Serverless
Lambda ASP.NET Core Web Application with Razor Pages serverless.AspNetCoreWebApp [C#] AWS/Lambda/Serverless
Serverless Detect Image Labels serverless.DetectImageLabels [C#], F# AWS/Lambda/Serverless
Lambda DynamoDB Blog API serverless.DynamoDBBlogAPI [C#] AWS/Lambda/Serverless
Lambda Empty Serverless serverless.EmptyServerless [C#], F# AWS/Lambda/Serverless
Lambda Giraffe Web App serverless.Giraffe F# AWS/Lambda/Serverless
Serverless Simple S3 Function serverless.S3 [C#], F# AWS/Lambda/Serverless
Step Functions Hello World serverless.StepFunctionsHelloWorld [C#], F# AWS/Lambda/Serverless
Console Application console [C#], F#, VB Common/Console
Class library classlib [C#], F#, VB Common/Library
Unit Test Project mstest [C#], F#, VB Test/MSTest
xUnit Test Project xunit [C#], F#, VB Test/xUnit
Razor Page page [C#] Web/ASP.NET
MVC ViewImports viewimports [C#] Web/ASP.NET
MVC ViewStart viewstart [C#] Web/ASP.NET
ASP.NET Core Empty web [C#], F# Web/Empty
ASP.NET Core Web App (Model-View-Controller) mvc [C#], F# Web/MVC
ASP.NET Core Web App razor [C#] Web/MVC/Razor Pages
ASP.NET Core with Angular angular [C#] Web/MVC/SPA
ASP.NET Core with React.js react [C#] Web/MVC/SPA
ASP.NET Core with React.js and Redux reactredux [C#] Web/MVC/SPA
Razor Class Library razorclasslib [C#] Web/Razor/Library/Razor Class Library
ASP.NET Core Web API webapi [C#], F# Web/WebAPI
global.json file globaljson Config
NuGet Config nugetconfig Config
Web Config webconfig Config
Solution File sln Solution

Examples:
dotnet new mvc --auth Individual
dotnet new serverless.AspNetCoreWebAPI
dotnet new --help
$

Closing the issue per @tanagoa comment.

Thanks, everyone!

Isn’t there still a bug.. why was a workaround needed?

Isn’t there still a bug.. why was a workaround needed?

we are not working around anything. @tanagoa returned the configuration to Japanese culture the problem is not reproed anymore. As I mentioned before we couldn't repro it either with the same configuration locally.

should i open it again? my dotnet core is good working now.

@tarekgh, I think what @jkotas meant was unsetting LC_ALL (so it is blank as in @tanagoa's original configuration) breaks the application is the problem here. Should we reopen this issue for tracking that or is there no good assumption / default that can be used?

In my mind:

Expected:

export LANG=ja_JP.UTF-8
unset LC_ALL
dotnet new -i Amazon.Lambda.Templates::*

should work

Actual

doesn't work

It is coming from https://github.com/dotnet/coreclr/blob/e5b7e4450a087240fc55a5174314605cee07b991/src/corefx/System.Globalization.Native/locale.cpp#L142. I have just finished converting that to C (https://github.com/dotnet/coreclr/pull/18614). It can be revisited once the PR is merged. The new name for this file is pal_locale.c.

@kasper3

It is coming from https://github.com/dotnet/coreclr/blob/e5b7e4450a087240fc55a5174314605cee07b991/src/corefx/System.Globalization.Native/locale.cpp#L142. I have just finished converting that to C (dotnet/coreclr#18614). It can be revisited once the PR is merged. The new name for this file is pal_locale.c.

Do you know the exact reason for the failure?
What is exactly wrong with the line

C# if (!IsEnvVarSet("LC_ALL") && !IsEnvVarSet("LC_MESSAGES") && !IsEnvVarSet("LANG"))

@tarekgh, not sure about the exact reason, but I was reading about it at https://unix.stackexchange.com/a/87763 and thought more could be done here. For example if LC_ALL is empty and LANG isn't, then maybe set LC_ALL? I am not able to reproduce it on Linux and I don't have MacBook.

To only mitigate loop in exception stack, then based on the callstack in top most comment

https://github.com/dotnet/coreclr/blob/0fbd855e38bc3ec269479b5f6bf561dcfd67cbb6/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.cs#L380

c# // in VerifyCultureName() 370 for (int i = 0; i < cultureName.Length; i++) 371 { 372 char c = cultureName[i]; 373 // TODO: Names can only be RFC4646 names (ie: a-zA-Z0-9) while this allows any unicode letter/digit 374 if (char.IsLetterOrDigit(c) || c == '-' || c == '_') 375 { 376 continue; 377 } 378 if (throwException) 379 { 380 throw new ArgumentException(SR.Format(SR.Argument_InvalidResourceCultureName, cultureName)); 381 } 382 return false; 383 }

SR.Format eventually calls string.Format with current culture which in turn calls VerifyCultureName. Maybe the fix here is not to use SR.Format but instead use string.Format with CultureInfo.InvariantCulture in throw statement if something has gone wrong (e.g. DefaultThreadCurrentUICulture has some invalid characters that does not satisfy condition on line#374)

@kasper3 I don't think VerifyCultureName is the problem at all nor the problem of calling SR.Format. we need to understand how we ended up with invalid culture name. I cannot repro it on my MAC either. I thought you already have a repro but it looks you don't.

@tanagoa if you do the following

export LANG=ja_JP.UTF-8
unset LC_ALL

on your machine, are you able to repro it? we need a repro to know what is going on.

Also, you may try

unset LANG
unset LC_ALL

I don't think VerifyCultureName is the problem at all nor the problem of calling SR.Format.

care to explain how?

care to explain how?

We should be initializing the CurrentUICulture which is used in the resources lookup from the user settings. Looks somehow in the failing case the culture name we got from the user settings containing some weird characters. VerifyCultureName is working as expected. It should fail on such names. The question now, how did we end up with this culture name on @tanagoa machine?

@tanagoa please update us if you can manage to repro the original problem on your machine. Thanks.

@tanagoa I am closing this and let me know if you able to repro the issue again in your side.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nalywa picture nalywa  ·  3Comments

chunseoklee picture chunseoklee  ·  3Comments

bencz picture bencz  ·  3Comments

jkotas picture jkotas  ·  3Comments

jzabroski picture jzabroski  ·  3Comments