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

When unload ietf-snmp-community.yang with augment, it read memory has been freed #459

Closed
dqdqddq opened this issue Mar 13, 2018 · 4 comments

Comments

@dqdqddq
Copy link

dqdqddq commented Mar 13, 2018

113  lydict_remove(struct ly_ctx *ctx, const char *value)
114  {
115      size_t len;
116      uint32_t index;
117      struct dict_rec *record, *prev = NULL;
118  
119      if (!value || !ctx) {
120          return;
121      }
122  
123     len = strlen(value);
124  
125     pthread_mutex_lock(&ctx->dict.lock);
126  
127     if (!ctx->dict.used) {
128          pthread_mutex_unlock(&ctx->dict.lock);
129          return;
130      }

read the memory has been freed here:

    #0 0xf723e7a7 in __interceptor_strlen ../../../asan/asan_interceptors.cc:600
    #1 0xf0f40269 in lydict_remove /libyang/yang/dict.c:123
    #2 0xf10e2a2d in module_free_common /libyang/yang/tree_schema.c:2678
    #3 0xf10e3d29 in lys_free /libyang/yang/tree_schema.c:3430
    #4 0xf0f370c2 in ly_ctx_destroy /libyang/yang/context.c:322

freed the memory for augment in unloading yang file here:

    #0 0xf72c7cd4 in __interceptor_free ../../../asan/asan_malloc_linux.cc:28
    #1 0xf0f40444 in lydict_remove /libyang/yang/dict.c:148
    #2 0xf10d0c8b in lys_type_free /libyang/yang/tree_schema.c:1925
    #3 0xf10d674f in lys_leaflist_free /libyang/yang/tree_schema.c:2211
    #4 0xf10d674f in lys_node_free /libyang/yang/tree_schema.c:2437
    #5 0xf10d509c in lys_node_free /libyang/yang/tree_schema.c:2419
    #6 0xf10d509c in lys_node_free /libyang/yang/tree_schema.c:2419
    #7 0xf10d73c6 in lys_augment_free /libyang/yang/tree_schema.c:2073
    #8 0xf10e1d2a in module_free_common /libyang/yang/tree_schema.c:2656
    #9 0xf10e3bd0 in lys_submodule_free /libyang/yang/tree_schema.c:2690
    #10 0xf10e1c77 in module_free_common /libyang/yang/tree_schema.c:2649
    #11 0xf10e3d29 in lys_free /libyang/yang/tree_schema.c:3430
    #12 0xf0f370c2 in ly_ctx_destroy /libyang/yang/context.c:322

previously allocated in loading yang file here:

    #0 0xf72c7e54 in __interceptor_malloc ../../../asan/asan_malloc_linux.cc:38
    #1 0x806ad1a in malloc syslib/frame_malloc.c:357
    #2 0xf0f2e2b9 in parse_text /libyang/yang/xml.c:710
    #3 0xf10eb49e in parse_attr /libyang/yang/xml.c:806
    #4 0xf10eb49e in lyxml_parse_elem /libyang/yang/xml.c:1066
    #5 0xf10ed008 in lyxml_parse_mem /libyang/yang/xml.c:1165
    #6 0xf1005bf1 in yin_read_module /libyang/yang/parser_yin.c:7100
    #7 0xf10e3f44 in lys_parse_mem_ /libyang/yang/tree_schema.c:961
    #8 0xf10e4337 in lys_parse_fd /libyang/yang/tree_schema.c:1115
    #9 0xf10e4703 in lys_parse_path /libyang/yang/tree_schema.c:1052
@dqdqddq dqdqddq changed the title unload ietf-snmp-community.yang read memory has been freed When unload ietf-snmp-community.yang with augment, it read memory has been freed Mar 13, 2018
@michalvasko
Copy link
Member

Hi,
could you please provide the relevant models (at least ones that cannot be found online, like the augment) and also the order in which you loaded them? Thanks.

Regards,
Michal

@michalvasko
Copy link
Member

Hi,
what do you mean by unload? I have tried parsing the modules and adding them into a context followed by ly_ctx_remove_module() and it worked as expected.

Regards,
Michal

@michalvasko
Copy link
Member

Hi,
could you please provide the output, your libyang version, and best also your code? You cannot load these modules one-by-one, you can only load ietf-snmp, which automatically loads all the submodules and imports so I still don't really understand what is it that you are doing.

Regards,
Michal

@michalvasko
Copy link
Member

Hi,
you have a year-and-a-half-old version of libyang so my suggestion is to update it and I am almost certain it will work.

Regards,
Michal

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

No branches or pull requests

2 participants