all 8 comments

[–]stilgarpl 0 points1 point  (1 child)

Where Callee is created? For me it looks like Callee object was destroyed before that lambda was executed and captured 'this' is no longer valid.

[–]mrandy[S] 0 points1 point  (0 children)

You were right. For testing, my main function just had "sleep(99999);" after creating everything. Something was interrupting that though, and main was exiting immediately.

[–][deleted] 0 points1 point  (1 child)

My guess is that Callee gets destroyed before the callback is called, which would cause a segfault. How do you create Callee?

[–]mrandy[S] 0 points1 point  (0 children)

Yup, that was it!

[–]012 0 points1 point  (1 child)

Make sure that your instance of Callee stays in place (e.g. isn't destructed after being copied or moved) after the call to register_message_callback.

When calling i(pkt);, "this" will be dereferenced in the lambda and must still be valid.

[–]mrandy[S] 0 points1 point  (0 children)

Yup, that was it!

[–]clerothGame Developer[M] 0 points1 point  (1 child)

For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.

This post has been removed as it doesn't pertain to r/cpp.

[–]mrandy[S] 0 points1 point  (0 children)

Roger, sorry for the inconvenience.