Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bug in "serialization fix" #67

Closed
mavam opened this Issue · 9 comments

2 participants

@mavam
Collaborator

After wondering why VAST does not work anymore with the lastest unstable, I had to figure out which commit was the culprit. This one: d209355. Before this commit, my messages arrive, but with this commit certain messages do not arrive anymore. Unfortunately I could not reproduce this with a small example. Here are some hopefully related random facts:

  • I use a1 << last_dequeued(); followed by a2 << last_dequeued();
  • I use forward_to(a)
@mavam
Collaborator

FYI: I updated the commit above. It is actually the "black magic" commit that causes the trouble: d209355.

@Neverlord
Owner

Well, commit d209355 changed the way libcppa writes serialized messages to a buffer and af1f91b adapts the middleman implementation to the new behavior.

However, I was not able to reproduce this bug by adding a forward_to over network test, so that's not the issue here (see 2c440b9).

Just to be sure, did you recompile & restart your program on all nodes after git pull? Do you use binary_serializer in your own code?

@mavam
Collaborator

Just to be sure, did you recompile & restart your program on all nodes after git pull?

Yeah, this is how I could narrow down the bug to a specific commit.

Do you use binary_serializer in your own code?

Not directly, I only use the generic cppa::serializer.

Seems like I have to do a bit more digging...

@mavam
Collaborator

The following example does not work for me; it hangs when sending the custom type. Would you mind checking?

#include <cppa/cppa.hpp>

using namespace cppa;

struct application
{
  application() = default;
  application(application const& other) = default;
  application(application&& other) = default;
  std::string data = "I hereby apply for a position.";
};

bool operator==(application const& x, application const& y)
{
  return x.data == y.data;
}

struct actress : sb_actor<actress>
{
  actress(actor_ptr t1, actor_ptr t2)
    : theatre1(t1)
    , theatre2(t2)
  {
  }

  behavior init_state = (
      on_arg_match >> [=](int age)
      {
        std::cout << "actress " << id() 
          << " sends age: " << age << std::endl;

        theatre1 << last_dequeued();
        theatre2 << last_dequeued(); 
      },
      on_arg_match >> [=](application const& app)
      {
        // XXX
        theatre1 << last_dequeued();
        theatre2 << last_dequeued();
        // Does not work either:
        //theatre1 << make_any_tuple(app);
        //theatre2 << make_any_tuple(app);
      },
      on_arg_match >> [=](bool allowed)
      {
        if (! allowed)
          return;

        application app;
        send(self, std::move(app));
        quit();
      });

  actor_ptr theatre1;
  actor_ptr theatre2;
};

struct theatre : sb_actor<theatre>
{
  behavior init_state = (
      on_arg_match >> [=](int age)
      {
        std::cout << "theatre " << id()
          << " can" << (age < 18 ? "not" : "")
          << " employ you" << std::endl;

        reply(age >= 18);
      },
      on_arg_match >> [=](application const& app)
      {
        std::cout << "theatre " << id() 
          << " proccesses application: " << app.data << std::endl;

        quit();
      });
};

int main()
{
  announce<application>(&application::data);
  auto t1 = spawn<theatre>();
  auto t2 = spawn<theatre>();
  publish(t1, 42000);
  publish(t2, 42001);
  auto rt1 = remote_actor("localhost", 42000);
  auto rt2 = remote_actor("localhost", 42001);
  auto a = spawn<actress>(rt1, rt2);
  send(a, 42);

  await_all_others_done();
  shutdown();
}
@Neverlord
Owner

Well, you did not announce application in this snippet.

@mavam
Collaborator

Surprisingly, adding

announce<application>(&application::data);

at the beginning of main() did not fix it.

@Neverlord
Owner

The code runs for me if you change reply(age < 18) to reply(age >= 18).

Btw, do you really have a use case for calling remote_actor to access local actors? I have patched the middleman and unicast_network to detect such "loops", so that it won't do any network traffic at all in such cases.

@mavam
Collaborator

It works for me too after applying your fix.

Update: Please try to run the updated example above and let me know if you can reproduce the hanging.

@mavam
Collaborator

Heck yea, 684c196 fixes this issue!

@mavam mavam closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.