Skip to content

add 'md:annotation default' to ietf-netconf-with-defaults will cause libyang2 coredump #2020

@jiayinhaoran

Description

@jiayinhaoran

When change ietf-netconf-with-defaults model like this:(add md:annotation default), and try to load this model using yanglint will cause coredump.

ietf-netconf-with-defaults@2011-06-01.yang
module ietf-netconf-with-defaults {
    namespace "urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults";
    prefix ncwd;
    import ietf-netconf { prefix nc; }
    import ietf-yang-metadata { prefix md; }
    organization
     "IETF NETCONF (Network Configuration Protocol) Working Group";
    contact
     "WG Web:   <http://tools.ietf.org/wg/netconf/>
      WG List:  <netconf@ietf.org>
      WG Chair: Bert Wijnen
                <bertietf@bwijnen.net>
      WG Chair: Mehmet Ersue
                <mehmet.ersue@nsn.com>
      Editor: Andy Bierman
              <andy.bierman@brocade.com>
      Editor: Balazs Lengyel
              <balazs.lengyel@ericsson.com>";
    description
     "This module defines an extension to the NETCONF protocol
      that allows the NETCONF client to control how default
      values are handled by the server in particular NETCONF
      operations.
      Copyright (c) 2011 IETF Trust and the persons identified as
      the document authors.  All rights reserved.
      Redistribution and use in source and binary forms, with or
      without modification, is permitted pursuant to, and subject
      to the license terms contained in, the Simplified BSD License
      set forth in Section 4.c of the IETF Trust's Legal Provisions
      Relating to IETF Documents
      (http://trustee.ietf.org/license-info).
      This version of this YANG module is part of RFC 6243; see
      the RFC itself for full legal notices.";
    revision 2011-06-01 {
      description
        "Initial version.";
      reference
       "RFC 6243: With-defaults Capability for NETCONF";
    }
    typedef with-defaults-mode {
       description
         "Possible modes to report default data.";
       reference
          "RFC 6243; Section 3.";
       type enumeration {
          enum report-all {
              description
                "All default data is reported.";
              reference
                "RFC 6243; Section 3.1";
          }
          enum report-all-tagged {
              description
                "All default data is reported.
                 Any nodes considered to be default data
                 will contain a 'default' XML attribute,
                 set to 'true' or '1'.";
              reference
                "RFC 6243; Section 3.4";
          }
          enum trim {
              description
                "Values are not reported if they contain the default.";
              reference
                "RFC 6243; Section 3.2";
          }
          enum explicit {
              description
                "Report values that contain the definition of
                 explicitly set data.";
              reference
                "RFC 6243; Section 3.3";
          }
      }
    }
    grouping with-defaults-parameters {
      description
        "Contains the <with-defaults> parameter for control
         of defaults in NETCONF retrieval operations.";
      leaf with-defaults {
        description
          "The explicit defaults processing mode requested.";
        reference
          "RFC 6243; Section 4.5.1";
        type with-defaults-mode;
      }
    }
    // extending the get-config operation
    augment /nc:get-config/nc:input {
        description
          "Adds the <with-defaults> parameter to the
           input of the NETCONF <get-config> operation.";
        reference
          "RFC 6243; Section 4.5.1";
        uses with-defaults-parameters;
    }
    // extending the get operation
    augment /nc:get/nc:input {
        description
          "Adds the <with-defaults> parameter to
           the input of the NETCONF <get> operation.";
        reference
          "RFC 6243; Section 4.5.1";
        uses with-defaults-parameters;
    }
    // extending the copy-config operation
    augment /nc:copy-config/nc:input {
        description
          "Adds the <with-defaults> parameter to
           the input of the NETCONF <copy-config> operation.";
        reference
          "RFC 6243; Section 4.5.1";
        uses with-defaults-parameters;
    }

  /*
   * Metadata annotations
   */
  md:annotation default {
    type boolean;
  }
}
yanglint
> add ietf-netconf-with-defaults@2011-06-01.yang
libyang[1]: Single revision of the module "ietf-yang-metadata" imported twice.
Segmentation fault

stack:
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7a701a1 in lys_parse_id (id=0x7fffffffd880) at /data/libyang2/libyang_build/src/src/common.c:608
608 if (!is_yangidentstartchar(**id)) {
(gdb) bt
#0 0x00007ffff7a701a1 in lys_parse_id (id=0x7fffffffd880) at /data/libyang2/libyang_build/src/src/common.c:608
#1 0x00007ffff7a70380 in ly_parse_nodeid (id=0x7fffffffd880, prefix=0x7fffffffd890, prefix_len=0x7fffffffd898, name=0x7fffffffd888, name_len=0x7fffffffd8a0)
at /data/libyang2/libyang_build/src/src/common.c:631
#2 0x00007ffff7af9960 in lysp_ext_find_definition (ctx=0x61b630, ext=0x638058, ext_mod=0x7fffffffd908, ext_def=0x638078) at /data/libyang2/libyang_build/src/src/tree_schema_common.c:2068
#3 0x00007ffff7ae609d in lysp_resolve_ext_instance_records (pctx=0x635a50) at /data/libyang2/libyang_build/src/src/tree_schema.c:1304
#4 0x00007ffff7ae8e63 in lys_parse_in (ctx=0x61b630, in=0x622f60, format=LYS_IN_YANG, custom_check=0x0, check_data=0x0, new_mods=0x61b6b0, module=0x7fffffffdab0)
at /data/libyang2/libyang_build/src/src/tree_schema.c:1826
#5 0x00007ffff7ae930f in lys_parse (ctx=0x61b630, in=0x622f60, format=LYS_IN_YANG, features=0x7fffffffdb30, module=0x0) at /data/libyang2/libyang_build/src/src/tree_schema.c:1913
#6 0x000000000040722b in cmd_add (ctx=0x618768 , cmdline=0x636950 "add ietf-netconf-with-defaults@2011-06-01.yang")
at /data/libyang2/libyang_build/src/tools/lint/cmd_add.c:160
#7 0x000000000040bc43 in main (argc=1, argv=0x7fffffffdd08) at /data/libyang2/libyang_build/src/tools/lint/main.c:84

version:
2.1.30

thanks @michalvasko

Metadata

Metadata

Assignees

No one assigned

    Labels

    is:bugBug description.status:invalidIssue is not reproducible or the behavior is intended.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions