-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Building a .NET Core Function SDK 8.0.201 on a MAC with M1 chip #72393
Comments
Unfortunately on .NET 8 and earlier the default stack size on Mac machines is much smaller than Windows / Linux. That means the compiler, which is naturally recursive in places, can run into limitations on Mac that it doesn't hit on other OS. That appears to be what is happening here. If possible would you be able to share the file in question here? I want to see if there is a particular pattern that we could recommend the function team change to make it harder to hit this issue. Note: in .NET 9 the situation should improve as the runtime team took steps to normalize stack space across OS |
The problem is that I can't tell exactly which file or files are causing this error. Only a reduction of the files in the function project brings success. Perhaps the problem could also come from the fact that our function has between 300 and 400 APIs. I am not aware of any complex code that could cause this stack overflow. |
@HeHubo based on the screen shot it's from a generated file called GeneratedFunctionExecutor.g.cs. I'm not 100% sure what is producing that but the file will either be in one of two places:
If this is code you can share out I'm happy to take a quick look at it and just find the file for you. If you need to share privately can file a VS Feedback issue, post the link here and we can get it going from that point. |
After I setting the EmitCompilerGeneratedFiles property in the project file, the build creates the file with the error. Here is the file: |
@cston looking at the generated code here, i'm not seeing the usual candidates for why the compiler hits stack limits. There is a very long chain of |
It looks like the parser will fail if there are too many For instance, the following results in class Program
{
static void F(int i)
{
if (i == 0) { }
else if (i == 0) { }
else if (i == 0) { }
else if (i == 0) { }
/* ... */
}
} |
That seems like something we should fix. There are limits that are hard to fix with nested exprs but chained statements like this should be oka.y |
An |
Also experiencing this chained We had to forcefully downgrade to SDK 8.0.102 for our project to build in CI, so we do have a workaround, but it sounds like this could show up again if cross a magic number of chain length. Erroring build: Referenced line is ~75% way through an We've also observed that Visual Studio based Build / Debugging does not trigger this issue compared to |
A fix for this is likely to show up in the VS 17.11 / .NET SDK 8.0.300 timeframe.
How do you get the source for that file?
That is a little surprising. The original bug filed here was due to compiling on Mac. The stack size on a Mac is significantly smaller than Windows / Linux hence hitting stack limitations in the compiler is more common there. The same stack size applies to |
Great to hear!
The actual source file causing us the error comes from a game modding project, which, while open source in patch form, we aren't allowed to publicly distribute the source files for. I can provide the source-code privately via email if you would like. Since we operate on patches, it's not very ideal for us to introduce new ones to split up functions into smaller parts, but we may do that in this case, as it seems like it's only one function that is failing to compile. That comes to my surprise however, as a lot of the game's logic happens to be unbelievably large else-if chains, and so yes, our project has most likely always been close to the compiler's limits. 🙃 |
You can send to [email protected] or open a VS feedback ticket, upload there and post a link in this issue. Either works for me. |
To support arbitrary length chains of
|
@cston for the ide, the set would also need to handle SyntaxWalker and SyntaxRewriter. Ide will likely die immediately due to our dependency on those compiler types, and their recursive behavior. |
We have observed that when using |
And in our case it seems to be linked with the number of Azure Functions we have 500+ in the project |
We are having the same issue after migrating our Azure Function App from .net 6 in-process to .Net 8 isolated. As a workaround for now (for those developing Azure Function), downgrading the package Microsoft.Azure.Functions.Worker.Sdk to 1.16.2 seems to do the trick. It starts failing to build starting in version 1.16.3. It's definitely not a fix, but it allows the build to work. |
Issue Description
Currently I getting an error while try to build my azure function project with the .NET SDK 8.0.201. I use an MAC with an M1 chip. On a Windows device with windows 11, the build runs successful.
I try many thinks to fix this error:
Steps to Reproduce
Expected Behavior
should compile ;-)
Actual Behavior
Error CS 8078 occurs
Analysis
No response
Versions & Configurations
MSBuild version 17.9.4+90725d08d for .NET
SDK 8.0.201
The text was updated successfully, but these errors were encountered: