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

Blazor WASM debugger faults when stepping through code #49218

Closed
RobertBouillon opened this issue Mar 5, 2021 · 5 comments · Fixed by #55915
Closed

Blazor WASM debugger faults when stepping through code #49218

RobertBouillon opened this issue Mar 5, 2021 · 5 comments · Fixed by #55915
Assignees
Labels
arch-wasm WebAssembly architecture area-Debugger-mono
Milestone

Comments

@RobertBouillon
Copy link

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).

@mkArtakMSFT mkArtakMSFT transferred this issue from dotnet/aspnetcore Mar 5, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Text.Json untriaged New issue has not been triaged by the area owner labels Mar 5, 2021
@ghost
Copy link

ghost commented Mar 5, 2021

Tagging subscribers to this area: @eiriktsarpalis, @layomia
See info in area-owners.md if you want to be subscribed.

Issue Details

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).

Author: RobertBouillon
Assignees: -
Labels:

area-System.Text.Json, untriaged

Milestone: -

@mkArtakMSFT mkArtakMSFT added arch-wasm WebAssembly architecture area-Debugger-mono and removed area-System.Text.Json untriaged New issue has not been triaged by the area owner labels Mar 5, 2021
@ghost
Copy link

ghost commented Mar 5, 2021

Tagging subscribers to this area: @thaystg
See info in area-owners.md if you want to be subscribed.

Issue Details

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).

Author: RobertBouillon
Assignees: -
Labels:

arch-wasm, area-Debugger-mono

Milestone: -

@mkArtakMSFT
Copy link
Member

@lewing FYI

@lewing lewing added this to the 6.0.0 milestone Jun 17, 2021
@lewing
Copy link
Member

lewing commented Jul 14, 2021

we've updated the stepping logic, this may be resolved.

thaystg added a commit to thaystg/runtime that referenced this issue Jul 19, 2021
@thaystg
Copy link
Member

thaystg commented Jul 19, 2021

It's fixed.

@thaystg thaystg closed this as completed Jul 19, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jul 19, 2021
thaystg added a commit that referenced this issue Jul 21, 2021
* Creating test to close 49143.

* Creating test to close #49141

* Adding test for #49218.

* Fix behavior of step to be the same of what we see when debugging using debugger-libs+mono or coreclr.
Fix error message of evaluate calling methods.
Adding test for #49142

* Improving test to test what @radical asked.

* Changing what was suggested by @radical.
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jul 21, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Aug 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-Debugger-mono
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants