Closed ZacharyPatten closed 1 year ago
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
@dotnet/illink-contrib a new issue has been filed in the ILLink area, please triage
The repro is to publish the /Projects/Marcala/Marcala.csproj
with /p:PublishTrimmed
.
The hang is in the analyzer, the LocalDataFlowAnalysis.InterproceduralAnalyze
never exits for the main method (the whole program is a top-level statement with some local functions).
I debugged into it somewhat and the problem is array value. One of the hoisted locals (called changes
in the code) is an array and each iteration of the interprocedural analysis ends up with a different state. But the difference is not caused by the analysis always finding something new. Instead there's a bug where the old state is not immutable and gets mutated by the analysis, so it's basically always doing the same thing, over and over again. I don't know exactly where the problem is yet - it's very likely a a missing value copy somewhere.
This is an analyzer only bug. Trimmer works just fine. Publishing the project with dotnet publish -c Release -r win-x64 --self-contained /p:PublishTrimmed=true /p:EnableTrimAnalyzer=false
succeeds without any hang.
@ZacharyPatten - you can apply a workaround by adding /p:EnableTrimAnalyzer=false
to the command line. Also - please don't try to add PublishTrimmed=true
into the project file - that would likely hang your IDE.
Note: The bug reproes in dotnet/runtime main branch as well.
Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas See info in area-owners.md if you want to be subscribed.
``` C:\Users\seven\source\repos\dotnet-console-games>dotnet publish dotnet-console-games.slnf --configuration Release --runtime win-x64 --self-contained /p:PublishTrimmed=true MSBuild version 17.5.1+f6fdcf537 for .NET Determining projects to restore... Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Simon\Simon.csproj (in 188 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Yahtzee\Yahtzee.csproj (in 138 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Whack A Mole\Whack A Mole.csproj (in 6 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Roll And Move\Roll And Move.csproj (in 198 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Helicopter\Helicopter.csproj (in 277 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Tower Of Hanoi\Tower Of Hanoi.csproj (in 224 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Snake\Snake.csproj (in 325 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Wumpus World\Wumpus World.csproj (in 330 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Sudoku\Sudoku.csproj (in 329 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Bound\Bound.csproj (in 336 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Memory\Memory.csproj (in 4 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Type\Type.csproj (in 71 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Duck Hunt\Duck Hunt.csproj (in 338 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Drive\Drive.csproj (in 39 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Pong\Pong.csproj (in 373 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Battleship\Battleship.csproj (in 90 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Hurdles\Hurdles.csproj (in 87 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Draw\Draw.csproj (in 115 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Quick Draw\Quick Draw.csproj (in 121 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Tic Tac Toe\Tic Tac Toe.csproj (in 435 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Beep Pad\Beep Pad.csproj (in 436 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Dice Game\Dice Game.csproj (in 88 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Checkers\Checkers.csproj (in 35 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Sliding Puzzle\Sliding Puzzle.csproj (in 183 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Connect 4\Connect 4.csproj (in 79 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\2048\2048.csproj (in 474 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Tanks\Tanks.csproj (in 503 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Wordle\Wordle.csproj (in 465 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Rythm\Rythm.csproj (in 38 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Guess A Number\Guess A Number.csproj (in 532 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Fighter\Fighter.csproj (in 156 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Rock Paper Scissors\Rock Paper Scissors.csproj (in 436 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Role Playing Game\Role Playing Game.csproj (in 34 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Blackjack\Blackjack.csproj (in 37 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Oligopoly\Oligopoly.csproj (in 533 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Gravity\Gravity.csproj (in 113 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Hangman\Hangman.csproj (in 114 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Tug Of War\Tug Of War.csproj (in 300 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Minesweeper\Minesweeper.csproj (in 206 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\PacMan\PacMan.csproj (in 30 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Mancala\Mancala.csproj (in 90 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Flappy Bird\Flappy Bird.csproj (in 156 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Tents\Tents.csproj (in 620 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Maze\Maze.csproj (in 123 ms). Whack A Mole -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Whack A Mole\bin\Release\Whack A Mole.dll Maze -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Maze\bin\Release\Maze.dll PacMan -> C:\Users\seven\source\repos\dotnet-console-games\Projects\PacMan\bin\Release\PacMan.dll Sudoku -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Sudoku\bin\Release\Sudoku.dll Connect 4 -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Connect 4\bin\Release\Connect 4.dll Snake -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Snake\bin\Release\Snake.dll Simon -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Simon\bin\Release\Simon.dll Helicopter -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Helicopter\bin\Release\Helicopter.dll Flappy Bird -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Flappy Bird\bin\Release\Flappy Bird.dll Whack A Mole -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Whack A Mole\bin\Release\win-x64\publish\ Tanks -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Tanks\bin\Release\Tanks.dll Pong -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Pong\bin\Release\Pong.dll Rythm -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Rythm\bin\Release\Rythm.dll Fighter -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Fighter\bin\Release\Fighter.dll 2048 -> C:\Users\seven\source\repos\dotnet-console-games\Projects\2048\bin\Release\2048.dll Minesweeper -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Minesweeper\bin\Release\Minesweeper.dll Wumpus World -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Wumpus World\bin\Release\Wumpus World.dll Beep Pad -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Beep Pad\bin\Release\Beep Pad.dll Hangman -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Hangman\bin\Release\Hangman.dll Hurdles -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Hurdles\bin\Release\Hurdles.dll Tic Tac Toe -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Tic Tac Toe\bin\Release\Tic Tac Toe.dll Connect 4 -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Connect 4\bin\Release\win-x64\publish\ PacMan -> C:\Users\seven\source\repos\dotnet-console-games\Projects\PacMan\bin\Release\win-x64\publish\ Sudoku -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Sudoku\bin\Release\win-x64\publish\ Maze -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Maze\bin\Release\win-x64\publish\ Snake -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Snake\bin\Release\win-x64\publish\ Rythm -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Rythm\bin\Release\win-x64\publish\ Wumpus World -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Wumpus World\bin\Release\win-x64\publish\ Minesweeper -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Minesweeper\bin\Release\win-x64\publish\ Fighter -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Fighter\bin\Release\win-x64\publish\ Simon -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Simon\bin\Release\win-x64\publish\ Tanks -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Tanks\bin\Release\win-x64\publish\ 2048 -> C:\Users\seven\source\repos\dotnet-console-games\Projects\2048\bin\Release\win-x64\publish\ Pong -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Pong\bin\Release\win-x64\publish\ Flappy Bird -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Flappy Bird\bin\Release\win-x64\publish\ Beep Pad -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Beep Pad\bin\Release\win-x64\publish\ Tic Tac Toe -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Tic Tac Toe\bin\Release\win-x64\publish\ Type -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Type\bin\Release\Type.dll Helicopter -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Helicopter\bin\Release\win-x64\publish\ Hangman -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Hangman\bin\Release\win-x64\publish\ Memory -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Memory\bin\Release\Memory.dll Role Playing Game -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Role Playing Game\bin\Release\Role Playing Game.dll Roll And Move -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Roll And Move\bin\Release\Roll And Move.dll Hurdles -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Hurdles\bin\Release\win-x64\publish\ Type -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Type\bin\Release\win-x64\publish\ Draw -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Draw\bin\Release\Draw.dll Sliding Puzzle -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Sliding Puzzle\bin\Release\Sliding Puzzle.dll Quick Draw -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Quick Draw\bin\Release\Quick Draw.dll Blackjack -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Blackjack\bin\Release\Blackjack.dll Bound -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Bound\bin\Release\Bound.dll Yahtzee -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Yahtzee\bin\Release\Yahtzee.dll Role Playing Game -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Role Playing Game\bin\Release\win-x64\publish\ Dice Game -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Dice Game\bin\Release\Dice Game.dll Wordle -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Wordle\bin\Release\Wordle.dll Drive -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Drive\bin\Release\Drive.dll Tents -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Tents\bin\Release\Tents.dll Roll And Move -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Roll And Move\bin\Release\win-x64\publish\ Guess A Number -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Guess A Number\bin\Release\Guess A Number.dll Memory -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Memory\bin\Release\win-x64\publish\ Battleship -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Battleship\bin\Release\Battleship.dll Dice Game -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Dice Game\bin\Release\win-x64\publish\ Rock Paper Scissors -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Rock Paper Scissors\bin\Release\Rock Paper Scissors.dll Sliding Puzzle -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Sliding Puzzle\bin\Release\win-x64\publish\ Drive -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Drive\bin\Release\win-x64\publish\ Quick Draw -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Quick Draw\bin\Release\win-x64\publish\ Tower Of Hanoi -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Tower Of Hanoi\bin\Release\Tower Of Hanoi.dll Draw -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Draw\bin\Release\win-x64\publish\ Blackjack -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Blackjack\bin\Release\win-x64\publish\ Yahtzee -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Yahtzee\bin\Release\win-x64\publish\ Tents -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Tents\bin\Release\win-x64\publish\ Wordle -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Wordle\bin\Release\win-x64\publish\ Tug Of War -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Tug Of War\bin\Release\Tug Of War.dll Bound -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Bound\bin\Release\win-x64\publish\ Oligopoly -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Oligopoly\bin\Release\Oligopoly.dll Guess A Number -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Guess A Number\bin\Release\win-x64\publish\ Checkers -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Checkers\bin\Release\Checkers.dll Tug Of War -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Tug Of War\bin\Release\win-x64\publish\ Battleship -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Battleship\bin\Release\win-x64\publish\ Oligopoly -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Oligopoly\bin\Release\win-x64\publish\ Tower Of Hanoi -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Tower Of Hanoi\bin\Release\win-x64\publish\ Gravity -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Gravity\bin\Release\Gravity.dll Duck Hunt -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Duck Hunt\bin\Release\Duck Hunt.dll Rock Paper Scissors -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Rock Paper Scissors\bin\Release\win-x64\publish\ Duck Hunt -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Duck Hunt\bin\Release\win-x64\publish\ Gravity -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Gravity\bin\Release\win-x64\publish\ Checkers -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Checkers\bin\Release\win-x64\publish\ ```
``` C:\Users\seven\source\repos\dotnet-console-games>dotnet --info .NET SDK: Version: 7.0.302 Commit: 990cf98a27 Runtime Environment: OS Name: Windows OS Version: 10.0.22621 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\7.0.302\ Host: Version: 7.0.5 Architecture: x64 Commit: 8042d61b17 .NET SDKs installed: 7.0.203 [C:\Program Files\dotnet\sdk] 7.0.302 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Other architectures found: x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation] Environment variables: Not set global.json file: Not found Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/download ```
Author: | ZacharyPatten |
---|---|
Assignees: | - |
Labels: | `untriaged`, `area-Tools-ILLink`, `needs-area-label` |
Milestone: | - |
Debugged some more - one bug I can confirm is in Maybe<T>
, it's used the value type for the hoisted locals dictionary, but it doesn't implement IDeepCopy<T>
, so when the hoisted locals dictionary is cloned from the current state to the old state, it doesn't get copied - we just copy the reference to the Maybe<T>
. And so when it gets modified in the next analysis pass, the old state also gets modified.
But fixing this (and then the same problem with ValueSet<T>
) still doesn't fix the problem. It just shifts it to a different hoisted local (pitsAndStores
) which then shows a similar wrong behavior.
Needs more debugging.
Higher-level thought: Especially in the analyzer we should avoid potentially endless loops. We should add a hard stop count to both the interprocedural and local analysis loops - to avoid hanging the IDE. Downside would be that we would never find this bug :-(
I just wanted to confirm that adding /p:EnableTrimAnalyzer=false
bypassed the issue. Thanks @vitek-karas. :)
Also, while looking at the code in the project having the issue I noticed a small unrelated bug and fixed it: https://github.com/dotnet/dotnet-console-games/commit/901c7b0fd487d99c3912bac869c872b03ef06d62. :P This issue is still occurring even after that small bug fix I applied. Just wanted to mention it if you see a slight difference while debugging/troubleshooting after pulling latest the code.
Thanks @ZacharyPatten for the confirmation.
Update on the debugging:
The second problem (after fixing the MaybeValueSet<T>
itself. It hits a case where the clone of the ValueSet<T>
is not equal to the original. This happens if the value set contains two values which are equal (in terms of IEquatable<T>
). I don't know how it got created yet, but the clone breaks the equality because:
I think this has to happen due to mutation of values, since the storage for ValueSet is HashSet, so the values could not have been equal at the time they were added to the ValueSet.
I think I know what's happening, but it's a complex problem and we probably don't want to solve it right now. The problem is that currently the data flow can really only model value types data flow (or immutable ref types like System.Type os System.String). We don't have a good model for mutable ref types. Arrays are mutable ref types.
ILLink (and NativeAOT) has parts of the solution since it supports by-ref values (ref parameters, ref fields, ...), but it's not the same thing.
Ultimately the problem is that if we read an array value from somewhere and then later on try to set an element in the array, we only modify the value we've got, we don't perform a write operation to where the array is stored. And this breaks the system.
A patch could be that we "Fixup" the problems which hurt analysis the most - that is equality. So one thing we could do is to implement DeepCopy and Equals in such a way that a copy if always equal to the input. This currently really affects ValueSet, and it probably might happen inside ArrayValue as well. This does not fix the full correctness problem, but it should fix the state management problem which is what's causing the endless loops.
Reactivating to consider this for 7.
https://github.com/dotnet/runtime/pull/86449 fixes the problem in main (.NET 8).
@vitek-karas, I'm seeing something similar with Microsoft Graph SDK for .NET in that it disappears into the ILLink
task. However, my publish
does eventually complete. Should I open a new issue?
https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/1811
There's a very neat repro for it using Microsoft's sample repro:
Expected: build completes in a timely manner Actual: build takes 1 hour
msbuild_.6.zip (This build fails with an error during AOT compile, for which I opened an issue https://github.com/xamarin/xamarin-macios/issues/18388 . Here I'm more concerned about the time spent in ILLink.)
If I omit Microsoft.Graph from the assemblies sent to the linker, it completes in < 10 mins. (The linker is only skipping/copying the Microsoft.Graph.dll, so I assume it's spending all its time doing some kind of analysis.)
<ItemGroup>
<UnanalyzableAssembly Include="Microsoft.Graph" />
</ItemGroup>
<Target Name="ConfigureTrimming"
BeforeTargets="PrepareForILLink">
<ItemGroup>
<_UnanalyzableManagedAssemblyToLink Include="@(UnanalyzableAssembly)" NuGetPackageId="%(Identity)" />
<ManagedAssemblyToLink Remove="@(_UnanalyzableManagedAssemblyToLink)" MatchOnMetadata="NuGetPackageId" />
</ItemGroup>
</Target>
@NickDarvey could you please create a new issue? It's not the same problem. If you were hitting the problem in this issue it wouldn't get to ILLink
task - it hangs the csc
compiler.
I spent like 10 minutes trying to build the repo on Windows, but it's complaining about weird things like "I need maui-tizen
" even though I'm asking it to build for Windows. So no luck.
@sbomer could you please give it a try on a mac?
I spent like 10 minutes trying to build the repo on Windows, but it's complaining about weird things like "I need
maui-tizen
" even though I'm asking it to build for Windows. So no luck.
I tried the repro as well. Since I did it on Windows from command line I opted to run dotnet publish -c Release -f net7.0-windows10.0.19041.0 -p:PublishTrimmed=true
instead of the iOS build. It run the linker but it finished in around a minute. By the time I attached the profiler I only got this:
https://github.com/dotnet/linker/pull/3217 has the 7.0 port of the fix for this issue.
Fix is merged
BUG:
PublishTrimmed
causingdotnet publish
to hangIn
.NET 7
there appears to be a bug that can causedotnet publish
commands to spin/hang indefinitely. I was not seeing this issue in.NET 6
so it must have been introduced in.NET 7
. It is specifically tied to the/p:PublishTrimmed=true
parameter.How To Reproduce
dotnet publish dotnet-console-games.slnf --configuration Release --runtime win-x64 --self-contained /p:PublishTrimmed=true
If I run the above command against the above repository it will hang indefinitely. If I leave off the
/p:PublishTrimmed=true
then it will finish as expected, so the bug appears to be tied to the addition of that parameter.Here is the output I get from the command before it hangs:
[ CLICK TO EXPAND ]
``` C:\Users\seven\source\repos\dotnet-console-games>dotnet publish dotnet-console-games.slnf --configuration Release --runtime win-x64 --self-contained /p:PublishTrimmed=true MSBuild version 17.5.1+f6fdcf537 for .NET Determining projects to restore... Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Simon\Simon.csproj (in 188 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Yahtzee\Yahtzee.csproj (in 138 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Whack A Mole\Whack A Mole.csproj (in 6 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Roll And Move\Roll And Move.csproj (in 198 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Helicopter\Helicopter.csproj (in 277 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Tower Of Hanoi\Tower Of Hanoi.csproj (in 224 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Snake\Snake.csproj (in 325 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Wumpus World\Wumpus World.csproj (in 330 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Sudoku\Sudoku.csproj (in 329 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Bound\Bound.csproj (in 336 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Memory\Memory.csproj (in 4 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Type\Type.csproj (in 71 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Duck Hunt\Duck Hunt.csproj (in 338 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Drive\Drive.csproj (in 39 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Pong\Pong.csproj (in 373 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Battleship\Battleship.csproj (in 90 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Hurdles\Hurdles.csproj (in 87 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Draw\Draw.csproj (in 115 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Quick Draw\Quick Draw.csproj (in 121 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Tic Tac Toe\Tic Tac Toe.csproj (in 435 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Beep Pad\Beep Pad.csproj (in 436 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Dice Game\Dice Game.csproj (in 88 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Checkers\Checkers.csproj (in 35 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Sliding Puzzle\Sliding Puzzle.csproj (in 183 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Connect 4\Connect 4.csproj (in 79 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\2048\2048.csproj (in 474 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Tanks\Tanks.csproj (in 503 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Wordle\Wordle.csproj (in 465 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Rythm\Rythm.csproj (in 38 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Guess A Number\Guess A Number.csproj (in 532 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Fighter\Fighter.csproj (in 156 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Rock Paper Scissors\Rock Paper Scissors.csproj (in 436 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Role Playing Game\Role Playing Game.csproj (in 34 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Blackjack\Blackjack.csproj (in 37 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Oligopoly\Oligopoly.csproj (in 533 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Gravity\Gravity.csproj (in 113 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Hangman\Hangman.csproj (in 114 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Tug Of War\Tug Of War.csproj (in 300 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Minesweeper\Minesweeper.csproj (in 206 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\PacMan\PacMan.csproj (in 30 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Mancala\Mancala.csproj (in 90 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Flappy Bird\Flappy Bird.csproj (in 156 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Tents\Tents.csproj (in 620 ms). Restored C:\Users\seven\source\repos\dotnet-console-games\Projects\Maze\Maze.csproj (in 123 ms). Whack A Mole -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Whack A Mole\bin\Release\Whack A Mole.dll Maze -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Maze\bin\Release\Maze.dll PacMan -> C:\Users\seven\source\repos\dotnet-console-games\Projects\PacMan\bin\Release\PacMan.dll Sudoku -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Sudoku\bin\Release\Sudoku.dll Connect 4 -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Connect 4\bin\Release\Connect 4.dll Snake -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Snake\bin\Release\Snake.dll Simon -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Simon\bin\Release\Simon.dll Helicopter -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Helicopter\bin\Release\Helicopter.dll Flappy Bird -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Flappy Bird\bin\Release\Flappy Bird.dll Whack A Mole -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Whack A Mole\bin\Release\win-x64\publish\ Tanks -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Tanks\bin\Release\Tanks.dll Pong -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Pong\bin\Release\Pong.dll Rythm -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Rythm\bin\Release\Rythm.dll Fighter -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Fighter\bin\Release\Fighter.dll 2048 -> C:\Users\seven\source\repos\dotnet-console-games\Projects\2048\bin\Release\2048.dll Minesweeper -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Minesweeper\bin\Release\Minesweeper.dll Wumpus World -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Wumpus World\bin\Release\Wumpus World.dll Beep Pad -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Beep Pad\bin\Release\Beep Pad.dll Hangman -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Hangman\bin\Release\Hangman.dll Hurdles -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Hurdles\bin\Release\Hurdles.dll Tic Tac Toe -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Tic Tac Toe\bin\Release\Tic Tac Toe.dll Connect 4 -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Connect 4\bin\Release\win-x64\publish\ PacMan -> C:\Users\seven\source\repos\dotnet-console-games\Projects\PacMan\bin\Release\win-x64\publish\ Sudoku -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Sudoku\bin\Release\win-x64\publish\ Maze -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Maze\bin\Release\win-x64\publish\ Snake -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Snake\bin\Release\win-x64\publish\ Rythm -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Rythm\bin\Release\win-x64\publish\ Wumpus World -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Wumpus World\bin\Release\win-x64\publish\ Minesweeper -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Minesweeper\bin\Release\win-x64\publish\ Fighter -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Fighter\bin\Release\win-x64\publish\ Simon -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Simon\bin\Release\win-x64\publish\ Tanks -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Tanks\bin\Release\win-x64\publish\ 2048 -> C:\Users\seven\source\repos\dotnet-console-games\Projects\2048\bin\Release\win-x64\publish\ Pong -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Pong\bin\Release\win-x64\publish\ Flappy Bird -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Flappy Bird\bin\Release\win-x64\publish\ Beep Pad -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Beep Pad\bin\Release\win-x64\publish\ Tic Tac Toe -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Tic Tac Toe\bin\Release\win-x64\publish\ Type -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Type\bin\Release\Type.dll Helicopter -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Helicopter\bin\Release\win-x64\publish\ Hangman -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Hangman\bin\Release\win-x64\publish\ Memory -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Memory\bin\Release\Memory.dll Role Playing Game -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Role Playing Game\bin\Release\Role Playing Game.dll Roll And Move -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Roll And Move\bin\Release\Roll And Move.dll Hurdles -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Hurdles\bin\Release\win-x64\publish\ Type -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Type\bin\Release\win-x64\publish\ Draw -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Draw\bin\Release\Draw.dll Sliding Puzzle -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Sliding Puzzle\bin\Release\Sliding Puzzle.dll Quick Draw -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Quick Draw\bin\Release\Quick Draw.dll Blackjack -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Blackjack\bin\Release\Blackjack.dll Bound -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Bound\bin\Release\Bound.dll Yahtzee -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Yahtzee\bin\Release\Yahtzee.dll Role Playing Game -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Role Playing Game\bin\Release\win-x64\publish\ Dice Game -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Dice Game\bin\Release\Dice Game.dll Wordle -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Wordle\bin\Release\Wordle.dll Drive -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Drive\bin\Release\Drive.dll Tents -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Tents\bin\Release\Tents.dll Roll And Move -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Roll And Move\bin\Release\win-x64\publish\ Guess A Number -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Guess A Number\bin\Release\Guess A Number.dll Memory -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Memory\bin\Release\win-x64\publish\ Battleship -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Battleship\bin\Release\Battleship.dll Dice Game -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Dice Game\bin\Release\win-x64\publish\ Rock Paper Scissors -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Rock Paper Scissors\bin\Release\Rock Paper Scissors.dll Sliding Puzzle -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Sliding Puzzle\bin\Release\win-x64\publish\ Drive -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Drive\bin\Release\win-x64\publish\ Quick Draw -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Quick Draw\bin\Release\win-x64\publish\ Tower Of Hanoi -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Tower Of Hanoi\bin\Release\Tower Of Hanoi.dll Draw -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Draw\bin\Release\win-x64\publish\ Blackjack -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Blackjack\bin\Release\win-x64\publish\ Yahtzee -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Yahtzee\bin\Release\win-x64\publish\ Tents -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Tents\bin\Release\win-x64\publish\ Wordle -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Wordle\bin\Release\win-x64\publish\ Tug Of War -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Tug Of War\bin\Release\Tug Of War.dll Bound -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Bound\bin\Release\win-x64\publish\ Oligopoly -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Oligopoly\bin\Release\Oligopoly.dll Guess A Number -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Guess A Number\bin\Release\win-x64\publish\ Checkers -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Checkers\bin\Release\Checkers.dll Tug Of War -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Tug Of War\bin\Release\win-x64\publish\ Battleship -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Battleship\bin\Release\win-x64\publish\ Oligopoly -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Oligopoly\bin\Release\win-x64\publish\ Tower Of Hanoi -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Tower Of Hanoi\bin\Release\win-x64\publish\ Gravity -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Gravity\bin\Release\Gravity.dll Duck Hunt -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Duck Hunt\bin\Release\Duck Hunt.dll Rock Paper Scissors -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Rock Paper Scissors\bin\Release\win-x64\publish\ Duck Hunt -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Duck Hunt\bin\Release\win-x64\publish\ Gravity -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Gravity\bin\Release\win-x64\publish\ Checkers -> C:\Users\seven\source\repos\dotnet-console-games\Projects\Checkers\bin\Release\win-x64\publish\ ```
Here is my
dotnet --info
:[ CLICK TO EXPAND ]
``` C:\Users\seven\source\repos\dotnet-console-games>dotnet --info .NET SDK: Version: 7.0.302 Commit: 990cf98a27 Runtime Environment: OS Name: Windows OS Version: 10.0.22621 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\7.0.302\ Host: Version: 7.0.5 Architecture: x64 Commit: 8042d61b17 .NET SDKs installed: 7.0.203 [C:\Program Files\dotnet\sdk] 7.0.302 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Other architectures found: x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation] Environment variables: Not set global.json file: Not found Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/download ```