Skip to content

Harmless debug assert hit in Uri's DebugAssertInCtor #124659

Closed

Description

@MihaZupan
// Uri.CreateThisFromUri fires Debug.Assert: (_flags & Flags.Debug_LeftConstructor) == 0
// when combining a UNC file URI base with a "file:" relative URI.
//
// Source: System.Uri.DebugAssertInCtor() at Uri.cs:205
//         System.Uri.CreateThisFromUri() at UriExt.cs:891

var baseUri = new Uri(@"\\aa", UriKind.Absolute);   // parses as file://aa/
var relUri = new Uri("file:", UriKind.Relative);
_ = new Uri(baseUri, relUri);                        // Debug.Assert failure

The assert violation is in CreateThisFromUri — it expects the constructor flag Debug_LeftConstructor to not be set, but the re-entrant URI construction from a UNC base + file: relative violates this invariant.

This is from the extra DebugAssertInCtor I added to DebugSetLeftCtor in #123932. We should either remove the assert or avoid copying the Debug_LeftConstructor flag in CreateThisFromUri.

Activity

  1. added this to the 11.0.0 milestone on Feb 20, 2026
  2. dotnet-policy-service commented on Feb 20, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @karelz, @dotnet/ncl
    See info in area-owners.md if you want to be subscribed.

  3. locked and limited conversation to collaborators on Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions