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

inheriting std::variant as table data segfaults #541

Closed
b1bart opened this issue Jun 25, 2019 · 2 comments
Closed

inheriting std::variant as table data segfaults #541

b1bart opened this issue Jun 25, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@b1bart
Copy link
Contributor

b1bart commented Jun 25, 2019

using v1.6.1 built locally on mac

this code appears to cause a segfault in eosio-cpp

goodbye.cpp:

#include <eosio/eosio.hpp>
#include <eosio/name.hpp>
#include <variant>

using namespace eosio;

class [[eosio::contract]] goodbye : public eosio::contract {
   public:
      goodbye(name receiver, name code, datastream<const char*> ds)
      :eosio::contract(receiver, code, ds)
      ,_foo(receiver, receiver.value)
      {}

      struct foo_v1 {
         uint64_t primary;
      };

      struct [[eosio::table]] foo : public std::variant<foo_v1> {
         uint64_t primary_key()const {
            return std::visit([](const auto& f){return f.primary; }, *this);
         }
      };

      using foo_table = eosio::multi_index<"foos"_n, foo>;

      foo_table _foo;

      [[eosio::action]]
      void hi(name nm) {
      }
};
@jeffreyssmith2nd
Copy link
Contributor

Confirmed on 1.6.2

@jeffreyssmith2nd jeffreyssmith2nd added the bug Something isn't working label Jul 17, 2019
conr2d added a commit to haderech/eoscc that referenced this issue Aug 25, 2019
`add_struct` enforces parsing its base as struct, and it causes segfault
when inheriting from the std types. This patch mitigates this issue
by allowing add_struct to call add_type for its base, but generated ABI is
still not usable, because chain::abi_serializer requires struct base to
be struct type. There is a workaround fix making it work by trick, but
ultimately it needs consensus upgrade.

EOSIO/eosio.cdt#541
conr2d added a commit to conr2d/eosio.cdt that referenced this issue Aug 25, 2019
`add_struct` enforces parsing its base as struct, and it causes segfault
when inheriting from the std types. This patch mitigates this issue
by allowing add_struct to call add_type for its base, but generated ABI is
still not usable, because chain::abi_serializer requires struct base to
be struct type. There is a workaround fix making it work by trick, but
ultimately it needs consensus upgrade.

EOSIO#541
conr2d added a commit to haderech/eoscc that referenced this issue Aug 25, 2019
`add_struct` enforces parsing its base as struct, and it causes segfault
when inheriting from the std types. This patch mitigates this issue
by allowing add_struct to call add_type for its base, but generated ABI is
still not usable, because chain::abi_serializer requires struct base to
be struct type. There is a workaround fix making it work by trick, but
ultimately it needs consensus upgrade.

EOSIO/eosio.cdt#541
larryk85 pushed a commit that referenced this issue Sep 27, 2019
`add_struct` enforces parsing its base as struct, and it causes segfault
when inheriting from the std types. This patch mitigates this issue
by allowing add_struct to call add_type for its base, but generated ABI is
still not usable, because chain::abi_serializer requires struct base to
be struct type. There is a workaround fix making it work by trick, but
ultimately it needs consensus upgrade.

#541
larryk85 pushed a commit that referenced this issue Oct 3, 2019
`add_struct` enforces parsing its base as struct, and it causes segfault
when inheriting from the std types. This patch mitigates this issue
by allowing add_struct to call add_type for its base, but generated ABI is
still not usable, because chain::abi_serializer requires struct base to
be struct type. There is a workaround fix making it work by trick, but
ultimately it needs consensus upgrade.

#541
@jeffreyssmith2nd
Copy link
Contributor

Fixed in 1.6.3

rise-worlds pushed a commit to potato-coin/eosio.cdt that referenced this issue Jul 14, 2020
`add_struct` enforces parsing its base as struct, and it causes segfault
when inheriting from the std types. This patch mitigates this issue
by allowing add_struct to call add_type for its base, but generated ABI is
still not usable, because chain::abi_serializer requires struct base to
be struct type. There is a workaround fix making it work by trick, but
ultimately it needs consensus upgrade.

EOSIO#541
rise-worlds pushed a commit to potato-coin/eosio.cdt that referenced this issue Jul 14, 2020
`add_struct` enforces parsing its base as struct, and it causes segfault
when inheriting from the std types. This patch mitigates this issue
by allowing add_struct to call add_type for its base, but generated ABI is
still not usable, because chain::abi_serializer requires struct base to
be struct type. There is a workaround fix making it work by trick, but
ultimately it needs consensus upgrade.

EOSIO#541
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants