Skip to content

Blazor WASM debugger faults when stepping through code #49218

Closed
@RobertBouillon

Description

@RobertBouillon

Describe the bug

Stepping through code causes fault (failed assertion) in mono.

To Reproduce

  1. Create a new Blazor WASM project
  2. Add a new .NET library project to the solution
  3. Add the Foo class to the library with the code below
  4. Add a reference to the .NET library project from the WASM project
  5. Update the FetchData.razor page with the code below.
  6. Add breakpoints at FetchData.razor:42 (Console.WriteLine...)
  7. Add this.Bar to the watch window.
  8. Start debugging. Wait for the debugger to attach before doing anything.
  9. Click on the "Fetch Data" link in the window
  10. The program should break in the FetchData.razor page. Press F5 to continue.
  11. Click on the "Home" link and then the "Fetch Data" link again
  12. The program should break in the FetchData.razor page. Press F11 twice to Step Into.

Expected Results

The debugger will step over the current statement

Actual Results

The debugger becomes unusable and must be restarted.

Comments

The problem appears to be caused by the expression this.Bar in the watch window: I'm unable to reproduce the error when the expression is removed.

Foo.cs

using System;
using System.Linq;
using System.Collections.Generic;

namespace BlazorBugsLib
{
  public class Foo
  {
    //public string Bar => "sample-data/weather.json";
    public string Bar => Stuffs.First(x => x.Name.StartsWith('S')).Name;
    public string Lorem { get; set; } = "Safe";
    public string Ipsum { get; set; } = "Side";
    public Something What { get; } = new Something();
    public List<Something> Stuffs { get; } = Enumerable.Range(0, 10).Select(x => new Something()).ToList();

    public int Bart()
    {
      int ret;
      if (Lorem.StartsWith('S'))
        ret = 0;
      else
        ret = 1;

      return ret;
    }
  }
}

FetchData.razor

  protected override async Task OnInitializedAsync()
  {
    Console.WriteLine(new BlazorBugsLib.Foo().Bart());
    forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("Bad URI");
  }

Output Window

mono_wasm_runtime_ready fe00e07a-5519-4dfe-b35a-f867dbaf2e28
0
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: '<' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
System.Text.Json.JsonException: '<' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
 ---> System.Text.Json.JsonReaderException: '<' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.
   at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
   at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
   at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first)
   at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
   at System.Text.Json.Utf8JsonReader.Read()
   at System.Text.Json.Serialization.JsonConverter`1[[BlazorBugs2.Pages.FetchData.WeatherForecast[], BlazorBugs2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   --- End of inner exception stack trace ---
   at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
   at System.Text.Json.Serialization.JsonConverter`1[[BlazorBugs2.Pages.FetchData.WeatherForecast[], BlazorBugs2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadCore[WeatherForecast[]](JsonConverter jsonConverter, Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadCore[WeatherForecast[]](JsonReaderState& readerState, Boolean isFinalBlock, ReadOnlySpan`1 buffer, JsonSerializerOptions options, ReadStack& state, JsonConverter converterBase)
   at System.Text.Json.JsonSerializer.<ReadAsync>d__20`1[[BlazorBugs2.Pages.FetchData.WeatherForecast[], BlazorBugs2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at System.Net.Http.Json.HttpContentJsonExtensions.<ReadFromJsonAsyncCore>d__3`1[[BlazorBugs2.Pages.FetchData.WeatherForecast[], BlazorBugs2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at System.Net.Http.Json.HttpClientJsonExtensions.<GetFromJsonAsyncCore>d__9`1[[BlazorBugs2.Pages.FetchData.WeatherForecast[], BlazorBugs2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at BlazorBugs2.Pages.FetchData.OnInitializedAsync() in C:\Users\rober\source\repos\BlazorBugs2\BlazorBugs2\Pages\FetchData.razor:line 43
   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)
>> mono_wasm_start_single_stepping 0
>> mono_wasm_start_single_stepping 0
: * Assertion at /__w/1/s/src/mono/mono/mini/debugger-engine.c:769, condition `<disabled>' not met

: * Assertion at /__w/1/s/src/mono/mono/mini/debugger-engine.c:769, condition `<disabled>' not met

Uncaught ExitStatusThe thread 0x2c50 has exited with code 0 (0x0).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions