Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

fix: local_service compile error loading file metadata #666

Merged
merged 5 commits into from
Nov 19, 2020

Conversation

neverchanje
Copy link
Contributor

@neverchanje neverchanje commented Nov 11, 2020

compilation error

/home/wutao1/git/pegasus/rdsn/include/dsn/cpp/json_helper.h:599:9:   required from ‘static bool dsn::json::json_forwarder< <template-parameter-1-1> >::decode(const dsn::blob&, T&) [with T = dsn::dist::block_service::file_metadata]’
/home/wutao1/git/pegasus/rdsn/src/block_service/local/local_service.cpp:247:54:   required from here
/home/wutao1/git/pegasus/rdsn/thirdparty/output/include/rapidjson/document.h:1952:24: error: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘rapidjson::GenericValue<rapidjson::UTF8<> >::Member’ {aka ‘struct rapidjson::GenericMember<rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<> >’} with no trivial copy-assignment; use copy-assignment instead [-Werror=class-memaccess]
 1952 |             std::memcpy(m, members, count * sizeof(Member));
      |             ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/wutao1/git/pegasus/rdsn/include/dsn/cpp/json_helper.h:40,
                 from /home/wutao1/git/pegasus/rdsn/src/block_service/local/local_service.cpp:10:
/home/wutao1/git/pegasus/rdsn/thirdparty/output/include/rapidjson/document.h:71:8: note: ‘rapidjson::GenericValue<rapidjson::UTF8<> >::Member’ {aka ‘struct rapidjson::GenericMember<rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<> >’} declared here
   71 | struct GenericMember {
      |        ^~~~~~~~~~~~~

This error seems not our fault, it's rapidjson to blame, considering it's been 4 years till its latest release (1.1.0).
So I replace it with nlohmann::json where local_service metadata converts to json.

I didn't figure out the true cause of this problem. Also, no other places using rapidjson were warned by gcc9.

As NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE provides so much powerful sugar to replace DEFINE_JSON_SERIALIZATION, I don't have the drive to dig into the root cause.

@neverchanje neverchanje added the thirdparty-modified If this PR modified some thirdparties that need to be entirely rebuilt. label Nov 11, 2020
acelyc111
acelyc111 previously approved these changes Nov 18, 2020
@neverchanje neverchanje merged commit b07c35c into XiaoMi:master Nov 19, 2020
@neverchanje neverchanje deleted the fix-local-service branch November 19, 2020 02:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
thirdparty-modified If this PR modified some thirdparties that need to be entirely rebuilt.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants