AL icon indicating copy to clipboard operation
AL copied to clipboard

Debugger crashes entirely if we're hovering over a variable

Open DavidFeldhoff opened this issue 4 years ago • 12 comments

Please include the following with each issue:

1. Describe the bug If we're hovering over a variable the debugger crashes entirely. This happens in the attached AL Project very often, but even there it's just a 90% crash, so a 100% example I can't deliver.

The error states:

Error: Field 'fieldParameters' defined on type 'Microsoft.Dynamics.Nav.BusinessApplication.Codeunit50100+CalculateValue_Scope__332826218' is not a field on the target object which is of type 'Microsoft.Dynamics.Nav.BusinessApplication.Codeunit50100+DoSomething1_Scope_1829286777'.

MicrosoftTeams-image (14)

https://user-images.githubusercontent.com/53570297/198226576-9bde55a5-ed33-4945-a088-92dbdce5d054.mp4

2. To Reproduce Steps to reproduce the behavior:

  1. Publish the attached extension to a v21 sandbox container.
  2. Open the Customer Card, so that the OnAfterGetCurrRecord trigger is executed
  3. Step through the procedures and just hover over the dictionary variable. Sometimes it crashes at the first procedure, sometimes just at the last, sometimes never. But it happens..
pageextension 50101 CustomerCardExtension extends "Customer Card"
{

    trigger OnAfterGetCurrRecord()
    var
        TaskParameters: Dictionary of [Text, Text];
    begin
        TaskParameters.Add('No.', Format(10000));
        CurrPage.EnqueueBackgroundTask(TaskID, Codeunit::RunBackgroundTask, TaskParameters);
    end;

    var
        TaskID: Integer;
}
codeunit 50100 RunBackgroundTask
{
    trigger OnRun()
    var
        TaskParameters: Dictionary of [Text, Text];
        Results: Dictionary of [Text, Text];
    begin
        TaskParameters := Page.GetBackgroundParameters();
        CalculateValue(Results, TaskParameters);
    end;

    local procedure CalculateValue(var Results: Dictionary of [Text, Text]; FieldParameters: Dictionary of [Text, Text])
    var
        ResultValue: Boolean;
    begin
        ResultValue := DoSomething1(FieldParameters);
        Results.Add('Test', Format(ResultValue));
        Page.SetBackgroundTaskResult(Results);
    end;

    local procedure DoSomething1(FieldParameters: Dictionary of [Text, Text]): Boolean
    begin
        exit(DoSomething2(FieldParameters));
    end;

    local procedure DoSomething2(FieldParameters: Dictionary of [Text, Text]): Boolean
    begin
        exit(DoSomething3(FieldParameters));
    end;

    local procedure DoSomething3(FieldParameters: Dictionary of [Text, Text]): Boolean
    begin
        exit(FieldParameters.ContainsKey('No.'));
    end;
}

3. Expected behavior That the debugger isn't crashing and shows instead the correct values

4. Actual behavior Debugger crashes entirely.

5. Versions:

  • AL Language: v10.0.687650
  • Visual Studio Code: Version: 1.72.2 (user setup)
  • Business Central: v21.0
  • List of Visual Studio Code extensions that you have installed: Only AL Language

DavidFeldhoff avatar Oct 27 '22 08:10 DavidFeldhoff

We experience the same issue but in standard code. The debugger crashes with undefined types in the base application. Debugging is a lottery now 99% of the time the debugger just crashes and we get "The debugger stopped your current activity."

image

Versions as stated above

Delirious-Grandpa avatar Nov 08 '22 13:11 Delirious-Grandpa

We experience the same issue but in standard code. The debugger crashes with undefined types in the base application. Debugging is a lottery now 99% of the time the debugger just crashes and we get "The debugger stopped your current activity."

image

Versions as stated above

Same for me today, cannot debug on AL Extension v10.1.707468.

mstjernfelt avatar Nov 18 '22 15:11 mstjernfelt

The scenario that produces this error is the following. Can you confirm please . a Procedure "foo" is calling procedure "bar" b. "bar" is called with a VAR record type (can be other types too, like above for Dictionaries). Let's name it myRecord. c. In "bar" you have a breakpoint you hover on the myRecord d. Execution returns to "foo" and you hover again on myRecord.

Remedy, until we fix it: do not hover on myRecord in "bar". Not before you have hovered it on "foo".

kalberes avatar Nov 18 '22 20:11 kalberes

Are there any new information about this issue. Debugger is crashing constantly... It is useless to start debugging. image.

mokolisan avatar Nov 28 '22 15:11 mokolisan

I also experienced crashes when debugging our code, one way to avoid the crash is to have different parameter names for each function. What I find is if two functions have the same parameter name, it increases the chance of crashing the debugger.

pageextension 50101 CustomerCardExtension extends "Customer Card"
{

    trigger OnAfterGetCurrRecord()
    var
        TaskParameters: Dictionary of [Text, Text];
    begin
        TaskParameters.Add('No.', Format(10000));
        CurrPage.EnqueueBackgroundTask(TaskID, Codeunit::RunBackgroundTask, TaskParameters);
    end;

    var
        TaskID: Integer;
}
codeunit 50100 RunBackgroundTask
{
    trigger OnRun()
    var
        TaskParameters: Dictionary of [Text, Text];
        Results: Dictionary of [Text, Text];
    begin
        TaskParameters := Page.GetBackgroundParameters();
        CalculateValue(Results, TaskParameters);
    end;

    local procedure CalculateValue(var Results: Dictionary of [Text, Text]; FieldParameters: Dictionary of [Text, Text])
    var
        ResultValue: Boolean;
    begin
        ResultValue := DoSomething1(FieldParameters);
        Results.Add('Test', Format(ResultValue));
        Page.SetBackgroundTaskResult(Results);
    end;

    local procedure DoSomething1(FieldParameters1: Dictionary of [Text, Text]): Boolean
    begin
        exit(DoSomething2(FieldParameters1));
    end;

    local procedure DoSomething2(FieldParameters2: Dictionary of [Text, Text]): Boolean
    begin
        exit(DoSomething3(FieldParameters2));
    end;

    local procedure DoSomething3(FieldParameters3: Dictionary of [Text, Text]): Boolean
    begin
        exit(FieldParameters3.ContainsKey('No.'));
    end;
}

carlosyuwono avatar Nov 28 '22 15:11 carlosyuwono

I've only debugged standard functionality... Crashes all the time... image

mokolisan avatar Nov 28 '22 15:11 mokolisan

Any news on this please? Our clients are now almost exclusively on V21 and we can't support them anymore. This causes us and our customers extreme frustration. And to put it more as above. It is not a lottery for us the debugger crashes 100% of the time in V21. It takes between 1 - 100 lines of code of debugging to achieve the "Debugger stopped your current activity"

Delirious-Grandpa avatar Nov 30 '22 08:11 Delirious-Grandpa

Bump +1 🦦

VS Code: 1.73.1 (system setup) AL Extension: v10.1.707468 Business Central: v21.0

christianbraeunlich avatar Nov 30 '22 13:11 christianbraeunlich

The fix for this issue has been checked in to the master branch. It will be available in the bcinsider.azurecr.io/bcsandbox-master Docker image starting from platform build number 22.0.49824.0 and VS Code Extension Version 11.0.713831.

If you don’t have access to these images you need to become part of the Ready2Go program: aka.ms/readytogo

For more details on code branches and docker images please read: https://blogs.msdn.microsoft.com/nav/2018/05/03/al-developer-previews-multiple-releases-and-github/ https://freddysblog.com/2020/06/25/working-with-artifacts/

JesperSchulz avatar Dec 01 '22 16:12 JesperSchulz

The fix for this issue has been checked in to the master branch. It will be available in the bcinsider.azurecr.io/bcsandbox-master Docker image starting from platform build number 22.0.49824.0 and VS Code Extension Version 11.0.713831.

If you don’t have access to these images you need to become part of the Ready2Go program: aka.ms/readytogo

For more details on code branches and docker images please read: https://blogs.msdn.microsoft.com/nav/2018/05/03/al-developer-previews-multiple-releases-and-github/ https://freddysblog.com/2020/06/25/working-with-artifacts/

Just to make sure, both BC platform and the .vsix need to be updated, right? Because I tried with the bcinsider .vsix for AL Language and the debugger still crashes on the current version of BC. @JesperSchulz

f0ffee avatar Dec 07 '22 16:12 f0ffee

@f0ffee This was a platform fix. Not a vsix. And I think it will only be available in January 2023 update.

kalberes avatar Dec 15 '22 17:12 kalberes

same Error after AL Extension v12.5.914975 update.

oksuzozkan avatar Jan 15 '24 12:01 oksuzozkan