Skip to content

Conversation

@MihaZupan
Copy link
Member

@MihaZupan MihaZupan commented Feb 15, 2020

Fixes #32374, fixes #32367

@MihaZupan MihaZupan added this to the 5.0 milestone Feb 15, 2020
@MihaZupan MihaZupan requested a review from jkotas February 15, 2020 16:10
@MihaZupan MihaZupan changed the title Fix stackalloc in a loop introduced by Fix stackalloc in a loop introduced by #32025 Feb 15, 2020
@davidfowl
Copy link
Member

This feels like an analyzer warning... Though of course there are cases where it would be fine.

@MihaZupan
Copy link
Member Author

@jkotas I was not aware that using stackalloc in a loop is a mistake.

Why is that so?

@MihaZupan MihaZupan requested a review from a team February 15, 2020 16:18
@jkotas
Copy link
Member

jkotas commented Feb 15, 2020

This feels like an analyzer warning

Yes, it was noted in #30740

I was not aware that using stackalloc in a loop is a mistake.

It allocates a new chunk of memory every time it is executed. The memory is released only once the method exits.

@stephentoub
Copy link
Member

Do we know why it only affected macOS? Are our default stack sizes different? Do we align or size stackallocs differently? Etc.

@jkotas
Copy link
Member

jkotas commented Feb 15, 2020

Yes, the default stack sizes differ between different OSes.

@stephentoub
Copy link
Member

stephentoub commented Feb 15, 2020

Yes, the default stack sizes differ between different OSes.

My surprise is that I was under the impression Linux (most distros) was significantly larger than Windows. This suggests macOS is significantly smaller.

Just looking it up now, seems the default size on macOS is indeed 512K.

@MihaZupan MihaZupan merged commit 68b05d4 into dotnet:master Feb 15, 2020
@jkotas
Copy link
Member

jkotas commented Feb 15, 2020

Yep, it is not the first time that this came up. E.g.: #12088 (comment)

@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System.Private.Uri.Functional.Tests failed with StackOverflow on OSX

5 participants