-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Parent pointer not properly set when using update() #3007
Labels
confirmed
kind: bug
release item: 🐛 bug fix
solution: proposed fix
a fix for the issue has been proposed and waits for confirmation
Milestone
Comments
Modifing for (auto it = j.cbegin(); it != j.cend(); ++it)
{
m_value.object->operator[](it.key()) = it.value();
#if JSON_DIAGNOSTICS
m_value.object->operator[](it.key()).m_parent = this;
#endif
} I can make a pull request with an extra unit test, but probably won't be able to get that done today. |
nlohmann
added
confirmed
solution: proposed fix
a fix for the issue has been proposed and waits for confirmation
state: waiting for PR
labels
Sep 9, 2021
Thanks for reporting, analyzing, and proposing a fix! It would be great if you could open a PR for this, as I won't have time to work on this before Sunday. |
The fix was super trivial as was the test, so here you go, PR submitted 😃. |
AnthonyVH
added a commit
to AnthonyVH/json
that referenced
this issue
Sep 9, 2021
AnthonyVH
added a commit
to AnthonyVH/json
that referenced
this issue
Sep 10, 2021
…so extend to test both update() functions.
AnthonyVH
added a commit
to AnthonyVH/json
that referenced
this issue
Sep 10, 2021
AnthonyVH
added a commit
to AnthonyVH/json
that referenced
this issue
Sep 12, 2021
4 tasks
nlohmann
pushed a commit
that referenced
this issue
Sep 12, 2021
…3008) * Set parent pointers for values inserted via update() (fixes #3007). * Moved test for #3007 to proper file. * Enable access to private members in diagnostics unit tests. * Make style consistent with rest of code. * Forced amalgamate rerun. * Refactor test for #3007 so it doesn't use private members. Also extend to test both update() functions. * Added fix for #3007 to update(const_iterator, const_iterator) as well. * Added failing example code from #3007 as extra test.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
confirmed
kind: bug
release item: 🐛 bug fix
solution: proposed fix
a fix for the issue has been proposed and waits for confirmation
When
update()
is used to insert new elements into annlohmann::json
, the parent pointers inside the newly inserted elements don't seem to be properly set.What is the issue you have?
When parent pointers are not set correctly, an assert goes off when
check_invariants()
is later called on the object. This only happens when JSON_DIAGNOSTICS is enabled.This might be related to #2926. Although as far as I can see, this has nothing to do with serialization.
Please describe the steps to reproduce the issue.
Live example: https://godbolt.org/z/Ms5hP35fW
Can you provide a small but working code example?
Same as the live code:
What is the expected behavior?
Parent pointers should be properly set. As a result no assert should go off.
And what is the actual behavior instead?
Parent pointers are not set, assertion goes off as a result.
Which compiler and operating system are you using?
Tested with:
Which version of the library did you use?
develop
branchThe text was updated successfully, but these errors were encountered: