dotnet / format

Home for the dotnet-format command

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sometimes dotnet-format analyzers exit with code 139 on CI

TSRBerry opened this issue · comments

I'm currently trying to adapt dotnet-format as part of our CI for new PRs, but have had some issues where dotnet-format would just crash at some point while the analyzers subcommand is running.

See this GitHub Actions run here: https://github.com/Ryujinx/Ryujinx/actions/runs/5569743230/jobs/10173389238#step:5:249
At the point where the crash occurs the following command is executed:

dotnet format analyzers --severity info --verify-no-changes --report ./analyzers-report.json -v d

It crashes with exit code 139 and without any other helpful information, so I'm unsure what to do.

I can confirm everything works locally with the same dotnet and dotnet-format version as the CI is using, so I have no clue what's going on.

I previously needed to downgrade to 4.4.0 as well, since 4.5.0 also crashed but I thought this was fixed when these issues were closed:

(Also I just realized how much spam I caused there by referencing the issues in my commit and rebasing my branch a bunch of times. I'm sorry about that.)


EDIT: After more investigation I was able to find out which commit actually caused dotnet-format to crash.
With this commit I was adding dotnet_naming_style rules back which I previously deleted, since I assumed dotnet-format would be using the default naming style rules on its own.

So something in these naming style rules causes dotnet-format to crash on CI:

#### Naming styles ####

# Naming rules

dotnet_naming_rule.interfaces_should_be_prefixed_with_I.severity = suggestion
dotnet_naming_rule.interfaces_should_be_prefixed_with_I.symbols = interface
dotnet_naming_rule.interfaces_should_be_prefixed_with_I.style = IPascalCase

dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = PascalCase

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = PascalCase

dotnet_naming_rule.private_static_readonly_fields_should_be_camel_case_and_prefixed_with__.symbols = private_static_readonly_fields
dotnet_naming_rule.private_static_readonly_fields_should_be_camel_case_and_prefixed_with__.severity = suggestion
dotnet_naming_rule.private_static_readonly_fields_should_be_camel_case_and_prefixed_with__.style = _camelCase

dotnet_naming_rule.local_constants_should_be_pascal_case.symbols = local_constants
dotnet_naming_rule.local_constants_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.local_constants_should_be_pascal_case.style = PascalCase

# Symbol specifications

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =

dotnet_naming_symbols.private_static_readonly_fields.applicable_kinds = field
dotnet_naming_symbols.private_static_readonly_fields.applicable_accessibilities = private
dotnet_naming_symbols.private_static_readonly_fields.required_modifiers = static, readonly

dotnet_naming_symbols.local_constants.applicable_kinds = local
dotnet_naming_symbols.local_constants.applicable_accessibilities = local
dotnet_naming_symbols.local_constants.required_modifiers = const

# Naming styles

dotnet_naming_style._camelCase.required_prefix = _
dotnet_naming_style._camelCase.required_suffix =
dotnet_naming_style._camelCase.word_separator =
dotnet_naming_style._camelCase.capitalization = camel_case

dotnet_naming_style.PascalCase.required_prefix =
dotnet_naming_style.PascalCase.required_suffix =
dotnet_naming_style.PascalCase.word_separator =
dotnet_naming_style.PascalCase.capitalization = pascal_case

dotnet_naming_style.IPascalCase.required_prefix = I
dotnet_naming_style.IPascalCase.required_suffix =
dotnet_naming_style.IPascalCase.word_separator =
dotnet_naming_style.IPascalCase.capitalization = pascal_case

The PR I'm referring to can be found here: Ryujinx/Ryujinx#4670

Some information about the CI environment:

  • dotnet-format version: 5.1.250801
  • dotnet sdk version: 7.0.306
  • dotnet runtime version: 7.0.9
  • Microsoft.CodeAnalysis.CSharp version: 4.6.0

If there is any other information I could include please let me know.

@TSRBerry v5.1.250801 is a very old build. Starting with the .NET 6 SDK, dotnet-format ships as part of the SDK and there is no need to install dotnet-format separately. See the announcement for more details about the updated CLI commands and options.

Oh that's embarrassing, sorry about that! I removed the command to install the global tool.
But sadly, the workflow still fails with exit code 139 for some reason.

Running dotnet format --version shows this version now: 7.3.426909+88adfff40b5b96258cd91c6ea681b25488ba8606

Hmm, maybe GitHub Actions is just that unstable now.

The workflow just finished successfully after adding the version command, which shouldn't change anything.
So in the end it might not be a dotnet-format issue after all.

I'll let you decide if this can be closed, since I really have no clue about this.


EDIT: Sorry that was wrong, the command was missing --severity info, so our naming style rules weren't checked.
Adding that snippet back will cause the process to crash with exit code 139 again, so there should be an issue here somewhere.

Since the formatting job here just worked, I'm pretty sure now that this is not a dotnet-format issue. Although naming style rules do make the issue more likely to occur, there must be something else going on if simply retrying already makes things work again.

You can find the retry logic I added to our workflow here:
https://github.com/Ryujinx/Ryujinx/blob/d6e58762f660208b49b761b10ac49f22d7bcdc94/.github/workflows/checks.yml#L51-L63