Skip to content
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

MethodBodyStreamEncoder.AddMethodBody ignores attributes for tiny methods. #24948

Closed
VSadov opened this issue Feb 6, 2018 · 4 comments · Fixed by #41613
Closed

MethodBodyStreamEncoder.AddMethodBody ignores attributes for tiny methods. #24948

VSadov opened this issue Feb 6, 2018 · 4 comments · Fixed by #41613
Labels
area-System.Reflection.Metadata disabled-test The test is disabled in source code against the issue
Milestone

Comments

@VSadov
Copy link
Member

VSadov commented Feb 6, 2018

RelatedTo:dotnet/roslyn#23951

MethodBodyStreamEncoder.AddMethodBody checks if it is possible to emit Tiny method header, and if it otherwise fits in Tiny, InitLocals flag get effectively ignored.

There is a case where we may need Fat format specifically because we want the InitLocals flag.
That happens if a method otherwise meets requirements of a Tiny format, but has stackalloc in it. If Tiny is used in such case, the caller will stackalloc a piece of nondeterministic garbage.

Overall - it should be up to the caller to decide whether the InitLocals is needed.
AddMethodBody should ensure that the flag is emitted if asked by the caller.

@VSadov
Copy link
Member Author

VSadov commented Feb 6, 2018

CC:@tmat

@VSadov
Copy link
Member Author

VSadov commented Feb 6, 2018

CC:@agocke, @t-camaia

For the time being, if we need to force the presence of the initlocals bit, we can workaround this by specifying stack size that is too large for a Tiny header.

Anything greater than 8 will work.

@stephentoub
Copy link
Member

@tmat, your PR dotnet/corefx#27589 closed this issue, but there are still two tests disabled against it:

[Fact, ActiveIssue("https://github.com/dotnet/corefx/issues/26910")]
public unsafe void LocAlloc()

[Fact, ActiveIssue("https://github.com/dotnet/corefx/issues/26910")]
public unsafe void LocAlloc_WithInstructionEncoder()

@stephentoub stephentoub reopened this Jan 23, 2020
@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 2.1.0 milestone Jan 31, 2020
@jkotas jkotas modified the milestones: 2.1.0, 5.0 Mar 1, 2020
@ericstj ericstj modified the milestones: 5.0.0, 6.0.0 Aug 31, 2020
@ericstj
Copy link
Member

ericstj commented Aug 31, 2020

Moving to 6.0.0

Remaining work is to re-enable these tests.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Reflection.Metadata disabled-test The test is disabled in source code against the issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants