[zeromq-dev] Mac OS X: test_shutdown_stress sometimes fails
Dhammika Pathirana
dhammika at gmail.com
Sat Nov 13 11:13:13 CET 2010
On Fri, Nov 12, 2010 at 11:10 PM, Martin Sustrik <sustrik at 250bpm.com> wrote:
> Hi Dhammika,
>>
>> 0 zmq::signaler_t::send()
>> 1 zmq::ctx_t::send_command()
>> 2 zmq::object_t::send_command()
>> 3 zmq::object_t::send_term_req()
>> 4 zmq::own_t::terminate()
>> 5 zmq::zmq_init_t::finalise_initialisation() !-- session deletes
>> the engine --!
>> 6 zmq::zmq_init_t::read()
>> 7 zmq::encoder_t::message_ready()
>> 8 zmq::encoder_base_t<zmq::encoder_t>::get_data()
>> 9 zmq::zmq_engine_t::out_event()
>> 10 zmq::kqueue_t::loop()
>> 11 zmq::kqueue_t::worker_routine()
>> 12 zmq::thread_t::thread_routine()
>>
>> In step 9, IO thread is calling engine_t::out_event() callback, and
>> the engine must be valid for the duration of this call.
>> But in step 5, session thread receives the engine and deletes it.
>> Don't you think there's a valid race here?
>>
>> engine->unplug() does detach the engine, but it only takes effect on
>> callback return.
>>
>
> I am not sure. The stack trace looks ok. How come session deletes the engine
> from zmq_init_t::finalise_initialisation?
In finalize_initialization(), we detach the engine and pass it over to
app thread.
engine->unplug ();
send_attach (session, engine, peer_identity, false);
engine = NULL;
terminate ();
But there's a stack reference to this engine object,
engine->out_event() callback.
I'll check if this shows up in valgrind.
Dhammika
More information about the zeromq-dev
mailing list