View of containers of `UPCXX_SERIALIZED_FIELDS` crashes in deserialization

Issue #391 resolved
john bachan created an issue

The following program crashes because deserialization miscalculates jump amounts when skipping over sequences of type foo when foo's serialization is UPCXX_SERIALIZED_[FIELDS|VALUES](args...) where all args are of trivial type.

Skipping is only instigated by views, so a vector<foo> alone would not trip this. A view<foo>, though also a sequence of foo, will also not trip this since view does not invoke serialization_reader::skip_sequence for non-trivially-serializable types, but skipping a container does.

#include <upcxx/upcxx.hpp>
#include <vector>

struct foo {
  char a; int b; char c;
  UPCXX_SERIALIZED_FIELDS(a,b,c)
};

int main() {
  upcxx::init();

  std::vector<foo> data[2]{
    {{'a',0xb,0xc},{0xa,'b',0xc},{0xa,0xb,'c'}},
    {{'a',0xb,0xc},{0xa,'b',0xc},{0xa,0xb,'c'}}
  };

  upcxx::rpc(upcxx::rank_me(),
    [=](upcxx::view<std::vector<foo>> v) {
      foo got = (*++v.begin())[0]; // grab 0'th elt from second vector
      UPCXX_ASSERT_ALWAYS(got.a=='a' && got.b==0xb && got.c==0xc);
    },
    upcxx::make_view(data, data+2)
  ).wait();

  upcxx::finalize();
}

Fix is small and forthcoming.

Comments (2)

  1. Dan Bonachea

    Fixed issue 391

    • Changed offset calc logic in skip_sequence to invoke ubound<T> on a prefix already containing a T and recording the difference.
    • Added test/regression/391.cpp
    • ChangeLog.md

    → <<cset 98a7a259c439>>

  2. Log in to comment