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

Read Access Violation on copy of existing element to new element #1011

Open
streetjimmothy opened this issue Jun 12, 2024 · 3 comments
Open

Comments

@streetjimmothy
Copy link

Version of Boost

1_84

Steps necessary to reproduce the problem

Expected Behaviour: assigning an existing property on a JSON to a key that does not exist should work the same as when the assignment is made to an existing key, or when any other value is assigned to a key that does not exist.
Actual Behaviour: read access violation
Case 1:
object["existing_key"] = object["old_key"]; //works
Case 2:
object["new_key"] = "new_value"; //works
Case 3:
object["new_key"] = object["old_key"]; //read access violation

Call stack & Error details:

Exception thrown: read access violation.
this was 0xFFFFFFFFFFFFFFFF.
boost_json-vc143-mt-gd-x64-1_84.dll!boost::container::pmr::memory_resource::is_equal(const boost::container::pmr::memory_resource & other) Line 59
boost_json-vc143-mt-gd-x64-1_84.dll!boost::container::pmr::operator==(const boost::container::pmr::memory_resource & a, const boost::container::pmr::memory_resource & b) Line 66
boost_json-vc143-mt-gd-x64-1_84.dll!boost::json::value::swap(boost::json::value & other) Line 390
boost_json-vc143-mt-gd-x64-1_84.dll!boost::json::value::operator=(const boost::json::value & other) Line 268

@streetjimmothy
Copy link
Author

As I was writing the above, I discovered that you don't get the error if any new element is assigned prior to the copy.
This works:
object["new_key"] = "new_value";
object["another_new_key"] = object["existing_key"];
This does not:
object["another_new_key"] = object["existing_key"]; //read access violation
object["new_key"] = "new_value";

@grisumbras
Copy link
Member

grisumbras commented Jun 12, 2024

Please provide a minimal complete verifiable example, so that I can attempt to reproduce the error. As is, I tried locally, and the error you are describing doesn't manifest.

@streetjimmothy
Copy link
Author

Thanks for the quick response; I'll whip one up in the next few days

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