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

Report error for native PDB limit #75293

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jjonescz
Copy link
Member

Resolves #75237.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 30, 2024
@jjonescz jjonescz marked this pull request as ready for review September 30, 2024 16:39
@jjonescz jjonescz requested a review from a team as a code owner September 30, 2024 16:39
public void NativeWriterLimit_Over(int length)
{
CompileWithMockedCustomMetadata(length).Diagnostics.Verify(
// error CS0041: Unexpected error writing debug information -- 'Insufficient memory to continue the execution of the program.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused. This test is linked to #75237 but exhibits the same/current behavior described in the issue.

Is this a different scenario than what customers had reported? Should we report a more specific error here (which limit was hit)?

Copy link
Member Author

@jjonescz jjonescz Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of these two tests (_Over and _Under) is to verify the exact limit value. To do that, they use a custom writer which intercepts metadata writes and passes a custom buffer with the specified size to the native writer (to see if it fails or not with the buffer). The specific error reporting logic happens before that, so it's not hit. I don't think there's a straightforward way to test that higher-level logic with exact buffer sizes. But NativeWriterLimit_EndToEnd tests the specific error (albeit the buffer size cannot be set exactly).

methodBody.MethodDefinition,
blob.Length,
limit));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: the name of the attribute is part of the limit length. Is that included in the blob?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the name is not included in the blob. You are right the limit is wrong now, will fix.

@@ -13,5 +13,10 @@ internal static class SymWriterTestUtilities
{
public static readonly Func<ISymWriterMetadataProvider, SymUnmanagedWriter> ThrowingFactory =
_ => throw new SymUnmanagedWriterException("xxx", new NotSupportedException(), "<lib name>");

public static SymUnmanagedWriter CreateUnmanagedWriter(ISymWriterMetadataProvider metadataProvider)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the benefit of this factory method vs. using SymUnmanagedWriterFactory.CreateWriter directly?

Copy link
Member Author

@jjonescz jjonescz Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SymUnmanagedWriterFactory when used from PDBTests raises a compile-time error because the type is defined both in Microsoft.DiaSymReader and Microsoft.CodeAnalysis assemblies. This utility project only references Microsoft.CodeAnalysis, so this factory method is a simple way to work around that problem (without the need for extern aliases).


namespace Roslyn.Test.PdbUtilities;

internal sealed class CustomMetadataSymUnmanagedWriter(SymUnmanagedWriter target, byte[] customMetadata) : DelegatingSymUnmanagedWriter(target)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CustomMetadataSymUnmanagedWriter

nit: if we don't feel this type will be used more generally, consider moving into PDBTests.cs

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it needs to be in this separate utility assembly, because in PDBTests some of the types would conflict between Microsoft.DiaSymReader and Microsoft.CodeAnalysis which are both referenced from there

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done with review pass (iteration 1). Only minor questions

@jcouv jcouv self-assigned this Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compiler should error when it hits native PDB writer limits
3 participants