Skip to content

Stack overflow while binding an InternalsVisibleTo attribute #57742

@AlekseyTs

Description

@AlekseyTs

Compile the following code into a library "csc /t:library lib.cs":

using System.Runtime.CompilerServices;

[ assembly: InternalsVisibleTo("debug, PublicKey=00240000048000009400000006020000002400005253413100040000010001002b986f6b5ea5717d35c72d38561f413e267029efa9b5f107b9331d83df657381325b3a67b75812f63a9436ceccb49494de8f574f8e639d4d26c0fcf8b0e9a1a196b80b6f6ed053628d10d027e032df2ed1d60835e5f47d32c9ef6da10d0366a319573362c821b5f8fa5abc5bb22241de6f666a85d82d6ba8c3090d01636bd2bb") ]
internal class PublicKeyConstants
{
	public const string PublicKey = "Something";
}

Compile the following code into another library "csc /t:library debug.cs /r:lib.dll":

using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("something" + PublicKeyConstants.PublicKey)]

Observed: compiler crashes due to a stack overflow.

Note that the attribute application in the second library doesn't have to be an InternalsVisibleTo. Any assembly level attribute with the same argument will cause a stack overflow. For example:

[assembly: TestAttribute("something" + PublicKeyConstants.PublicKey)]

class TestAttribute : System.Attribute
{
	public TestAttribute(string x) {} 
}

Metadata

Metadata

Assignees

Labels

Area-CompilersBuguntriagedIssues and PRs which have not yet been triaged by a lead

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions