Skip to content

Segfault on direct initializing json object #973

Description

@dns13

I'm currently updating from 2.x to 3.1.1: Now my default initialisation of json objects is causing a SEGFAULT:

Example:

json root = {
    {"command", "request_token"},
    {"payload", {
        {"token", child_info.token}
    }}
};

This code is working fine:

json root;
root = {
    {"command", "request_token"},
    {"payload", {
        {"token", child_info.token}
    }}
};

I'm experiencing this in only one single way to call the containing function:
I'm using a command string parsed from an json object, and a std::map to map that string to an enumeration object, which I pass to a switch statement to determine which function to be called.

If I skip the switch statement, and determine the calling of the function by directly comparing the command string, it won't crash.

I'm using gcc 4.9.2 with cross compiling to armv7.

Heres a backtrace after crashing:

#0  0x0003e32c in nlohmann::basic_json<std::map, std::vector, std::string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer>::json_value::destroy(nlohmann::detail::value_t) ()
#1  0x0002cef4 in int (anonymous namespace)::command_expr_request_token<0, 0>(nlohmann::basic_json<std::map, std::vector, std::string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer> const&, conn_info_t&, bio_st*, int, bool) [clone .isra.1043] ()
#2  0x00044b38 in parseCommand(nlohmann::basic_json<std::map, std::vector, std::string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer> const&, conn_info_t&, bio_st*) ()
#3  0x0006e4b4 in (anonymous namespace)::thread_child(bio_st*) ()
#4  0x4b2c7f68 in ?? () from /usr/lib/libstdc++.so.6
#5  0x4b146068 in ?? () from /lib/libpthread.so.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions