Skip to content

union: remove assert in sort #2361

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

Merged
merged 1 commit into from
Mar 3, 2025

Conversation

bradh352
Copy link
Contributor

Getting assertion in lyplg_type_sort_union(). This assertion appears invalid as it comes up in test cases in SONiC but when removed everything passes.

Copy link
Member

@michalvasko michalvasko left a comment

Choose a reason for hiding this comment

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

I believe the assert is relevant and I would guess the issue is caused by leafrefs, not sure why it did not come up sooner. Try using the following code for the loop and see whether that fixes the assert.

    struct lysc_type *type; /* put next to the other declarations */

    /* compare according to the order of types */
    types = ((struct lysc_type_union *)val1->realtype)->types;
    LY_ARRAY_FOR(types, u) {
        if (types[u]->basetype == LY_TYPE_LEAFREF) {
            type = ((struct lysc_type_leafref *)types[u])->realtype;
        } else {
            type = types[u];
        }
        if (type == val1->subvalue->value.realtype) {
            rc = 1;
            break;
        } else if (type == val2->subvalue->value.realtype) {
            rc = -1;
            break;
        }
    }

An assert was being hit in lyplg_type_sort_union() when evaluating
leafrefs due to not using the realtype node.

Signed-off-by: Michal Vasko <[email protected]>
Signed-off-by: Brad House <[email protected]>
@bradh352 bradh352 force-pushed the bradh352/union_sort_assert branch from 7e3a716 to 18dd3a6 Compare March 3, 2025 11:24
@bradh352
Copy link
Contributor Author

bradh352 commented Mar 3, 2025

I believe the assert is relevant and I would guess the issue is caused by leafrefs, not sure why it did not come up sooner. Try using the following code for the loop and see whether that fixes the assert.

You're right, I should have spent more time evaluating this. Your patch works properly. All test cases in both libyang and sonic-mgmt-common pass with your change. I've updated this PR to use your change.

@michalvasko michalvasko merged commit 5f20e92 into CESNET:devel Mar 3, 2025
11 checks passed
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Mar 3, 2025
@bradh352 bradh352 deleted the bradh352/union_sort_assert branch March 3, 2025 15:17
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Mar 4, 2025
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Mar 5, 2025
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Mar 5, 2025
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Mar 6, 2025
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Mar 8, 2025
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Mar 11, 2025
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Mar 12, 2025
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Apr 3, 2025
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Apr 3, 2025
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Apr 20, 2025
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Apr 22, 2025
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Apr 23, 2025
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Apr 24, 2025
bradh352 added a commit to bradh352/sonic-buildimage that referenced this pull request Jun 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants