Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault in intrusive_ptr destructor #49

Closed
mavam opened this issue Jul 31, 2012 · 3 comments
Closed

Segfault in intrusive_ptr destructor #49

mavam opened this issue Jul 31, 2012 · 3 comments
Labels

Comments

@mavam
Copy link
Collaborator

mavam commented Jul 31, 2012

I haven't managed to write a small test case, but here is already the stacktrace. Ideally you know what's going on, but I believe this requires more context. The troublemaker is a cow_tuple<T> stored outside a libcppa handler. I obtain the cow_tuple as follows:

auto opt = tuple_cast<T>(last_dequeued());
assert(opt.valid());
f(*opt); // stores *opt.

As the actors terminate, this segfault occurs:

#0  0x0000000000000035 in ?? ()
#1  0x00007ffff7a94bd5 in cppa::intrusive_ptr<cppa::process_information>::~intrusive_ptr (this=0x7fffac000b80, __in_chrg=<optimized out>) at /home/matthias/opt/gcc/include/cppa/intrusive_ptr.hpp:88
#2  0x00007ffff671fe0b in cppa::detail::tdata<cppa::intrusive_ptr<cppa::process_information>, cppa::detail::addressed_message>::~tdata (this=0x7fffac000b58, __in_chrg=<optimized out>) at /home/matthias/libcppa/./cppa/detail/tdata.hpp:227
#3  0x00007ffff67226c1 in cppa::detail::tuple_vals<cppa::intrusive_ptr<cppa::process_information>, cppa::detail::addressed_message>::~tuple_vals (this=0x7fffac000b40, __in_chrg=<optimized out>) at /home/matthias/libcppa/./cppa/detail/tuple_vals.hpp:46
#4  0x00007ffff6722720 in cppa::detail::tuple_vals<cppa::intrusive_ptr<cppa::process_information>, cppa::detail::addressed_message>::~tuple_vals (this=0x7fffac000b40, __in_chrg=<optimized out>) at /home/matthias/libcppa/./cppa/detail/tuple_vals.hpp:46
#5  0x00007ffff7b6ab53 in cppa::intrusive_ptr<cppa::detail::abstract_tuple>::reset (this=0x61b818, new_value=0x617fc0) at /home/matthias/opt/gcc/include/cppa/intrusive_ptr.hpp:113
#6  0x00007ffff7b697e1 in cppa::cow_ptr<cppa::detail::abstract_tuple>::reset (this=0x61b818, value=0x617fc0) at /home/matthias/opt/gcc/include/cppa/cow_ptr.hpp:88
#7  0x00007ffff6729af9 in cppa::any_tuple::reset (this=0x61b818) at /home/matthias/libcppa/src/any_tuple.cpp:59
#8  0x00007ffff6736c01 in cppa::detail::abstract_actor<cppa::local_actor>::release_node (this=0x61b540, node=0x61b800) at /home/matthias/libcppa/./cppa/detail/abstract_actor.hpp:210
#9  0x00007ffff6735f8d in cppa::detail::receive_policy::invoke<cppa::thread_mapped_actor, cppa::behavior> (this=0x61b738, client=0x61b540, node=0x61b800, fun=..., awaited_response=...) at /home/matthias/libcppa/./cppa/detail/receive_policy.hpp:113
#10 0x00007ffff6735d77 in cppa::detail::receive_policy::receive_wo_timeout<cppa::thread_mapped_actor, cppa::behavior> (this=0x61b738, client=0x61b540, fun=...) at /home/matthias/libcppa/./cppa/detail/receive_policy.hpp:137
#11 0x00007ffff6735276 in cppa::detail::receive_policy::receive<cppa::thread_mapped_actor> (this=0x61b738, client=0x61b540, bhvr=...) at /home/matthias/libcppa/./cppa/detail/receive_policy.hpp:149
#12 0x00007ffff6734b24 in cppa::detail::stacked_actor_mixin<cppa::thread_mapped_actor, cppa::detail::abstract_actor<cppa::local_actor> >::dequeue (this=0x61b540, bhvr=...) at /home/matthias/libcppa/./cppa/detail/stacked_actor_mixin.hpp:64
#13 0x00007ffff674b712 in cppa::detail::do_receive_helper::until<cppa::ge_reference_wrapper<bool> >(cppa::ge_reference_wrapper<bool>&&) (this=0x7ffff270f8d0, stmt=...) at /home/matthias/libcppa/./cppa/detail/receive_loop_helper.hpp:122
#14 0x00007ffff6745bfb in cppa::detail::mailman_loop () at /home/matthias/libcppa/src/mailman.cpp:114
#15 0x00007ffff674dd2a in operator() (__closure=0x61ba50) at /home/matthias/libcppa/src/network_manager.cpp:82
#16 0x00007ffff675038e in std::_Bind_simple<{anonymous}::network_manager_impl::start()::<lambda()>()>::_M_invoke<>(std::_Index_tuple<>) (this=0x61ba50) at /home/matthias/opt/gcc/lib/gcc/x86_64-redhat-linux/4.7.0/../../../../include/c++/4.7.0/functional:1598
#17 0x00007ffff6750269 in std::_Bind_simple<{anonymous}::network_manager_impl::start()::<lambda()>()>::operator()(void) (this=0x61ba50) at /home/matthias/opt/gcc/lib/gcc/x86_64-redhat-linux/4.7.0/../../../../include/c++/4.7.0/functional:1586
#18 0x00007ffff675019a in std::thread::_Impl<std::_Bind_simple<{anonymous}::network_manager_impl::start()::<lambda()>()> >::_M_run(void) (this=0x61ba38) at /home/matthias/opt/gcc/lib/gcc/x86_64-redhat-linux/4.7.0/../../../../include/c++/4.7.0/thread:115
#19 0x00007ffff55f76c0 in std::(anonymous namespace)::execute_native_thread_routine (__p=<optimized out>) at ../../../../../libstdc++-v3/src/c++11/thread.cc:73
#20 0x0000003191207b31 in start_thread () from /lib64/libpthread.so.0
#21 0x0000003190edfd2d in clone () from /lib64/libc.so.6

System: 64-bit Linux with GCC 4.7.

@Neverlord
Copy link
Member

I don't think tuple_cast is the problem here, since the following runs just fine.

int main() {
    cow_tuple<int> itup;
    cow_tuple<int> itup2;

    send(self, 42);
    send(self, 1, 2.0f);
    int i = 0;
    receive_for(i, 2) (
        on<int>() >> [&] {
            auto opt = tuple_cast<int>(self->last_dequeued());
            if (opt) itup = *opt;
            else cerr << "WTF? tuple_cast failed in line " << __LINE__ << endl;
        },
        on<int, float>() >> [&] {
            auto opt = tuple_cast<int, anything>(self->last_dequeued());
            if (opt) itup2 = *opt;
            else cerr << "WTF? tuple_cast failed in line " << __LINE__ << endl;
        }
    );
    cout << get<0>(itup) << endl;
    cout << get<0>(itup2) << endl;
    return 0;
}

However, the stack trace points to mailman_loop, which is part of libcppa's network layer. So it might be serialization issue.

@mavam
Copy link
Collaborator Author

mavam commented Aug 15, 2012

This one does not seem to crop up anymore after pulling from unstable. Let's keep the issue open after a bit more testing.

@mavam
Copy link
Collaborator Author

mavam commented Aug 15, 2012

I am closing this issue after not being able to reproduce it anymore.

@mavam mavam closed this as completed Aug 15, 2012
Neverlord added a commit that referenced this issue Apr 21, 2022
Update CMake scaffold
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants