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

Bugfix/segfault in log #2215

Closed
wants to merge 1 commit into from
Closed

Conversation

steweg
Copy link
Contributor

@steweg steweg commented Apr 4, 2024

No description provided.

@steweg steweg changed the base branch from master to devel April 4, 2024 06:47
@michalvasko
Copy link
Member

When does this occur? Even the comment says that the error code is being inherited, if there is no previous error, it is probably a bug.

@steweg
Copy link
Contributor Author

steweg commented Apr 4, 2024

I was not able to quickly determine that as I was working with very complex data when it happens. I have pinpoint it using valgrind, but anyway I will dig further and let you know

michalvasko added a commit that referenced this pull request Apr 5, 2024
@steweg
Copy link
Contributor Author

steweg commented Apr 5, 2024

I was able to recreate it, but I was not able to find out how to better fix it. Here is what is needed to reproduce:
a.yang file:

module a {
  namespace "a";
  prefix a;
  list a {key a1; leaf a1 {type string;} leaf a2 {type string;}}
  leaf b {type leafref {path "../a/a1";}}
  leaf c {type leafref {path "deref(../b)/../a2";}}
}

a.json file:

{
  "a:a": [{"a1": "valA1", "a2": "valB1"}, {"a1": "valA2", "a2": "valB2"}],
  "a:b": "valC1",
  "a:c": "valB1"
}

Output of the following command:

valgrind --exit-on-first-error=yes  --leak-check=full --show-leak-kinds=all --error-exitcode=1 yanglint a.yang -X -f json a.json
==29657== Memcheck, a memory error detector
==29657== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==29657== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==29657== Command: yanglint a.yang -X -f json a.json
==29657==
==29657== Invalid read of size 4
==29657==    at 0x486E476: log_vprintf (log.c:642)
==29657==    by 0x486E8AC: ly_log (log.c:717)
==29657==    by 0x49874D5: xpath_deref (xpath.c:4078)
==29657==    by 0x49941FD: eval_function_call (xpath.c:8746)
==29657==    by 0x4994B0B: eval_path_expr (xpath.c:8936)
==29657==    by 0x499700F: eval_expr_select (xpath.c:9633)
==29657==    by 0x499752E: lyxp_eval (xpath.c:9741)
==29657==    by 0x496EE28: lyplg_type_resolve_leafref (plugins_types.c:1050)
==29657==    by 0x49A59C9: lyplg_type_validate_leafref (leafref.c:83)
==29657==    by 0x4897968: lyd_value_validate_incomplete (tree_data_common.c:563)
==29657==    by 0x499920B: lyd_validate_unres (validation.c:389)
==29657==    by 0x499D6F9: lyd_validate (validation.c:1871)
==29657==  Address 0x8 is not stack'd, malloc'd or (recently) free'd
==29657==
==29657==
==29657== Exit program on first error (--exit-on-first-error=yes)

Hope it helps

@michalvasko
Copy link
Member

michalvasko commented Apr 5, 2024

I have just decided to get rid of this "feature", not a good idea in general. So unless I missed a use-case (the one you posted works), it should be fixed.

@steweg
Copy link
Contributor Author

steweg commented Apr 5, 2024

Ok, closing this PR

@steweg steweg closed this Apr 5, 2024
@steweg steweg deleted the bugfix/segfault-in-log branch April 5, 2024 07:15
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