Home Bug Reports

Ice 3.6 Why ice crash after proxy be null?

sepcitysepcity Member Daniel YuanOrganization: fsmeetingProject: Video Conference
My slice define like this
#ifndef _CRASH_ICE_
#define _CRASH_ICE_

module Crash
{

["ami", "amd"] interface TestClass
{

int AmiInvokeMethod();
int DirectInvokeMethod();

};


};

#endif // _CRASH_ICE_

client invoke AmiInvokeMethod asynchronous and DirectInvokeMethod synchronized

Callback_TestClass_AmiInvokeMethodPtr cb = newCallback_TestClass_AmiInvokeMethod
(new TestClass_AmiInvokeMethod_CallBack(),
&TestClass_AmiInvokeMethod_CallBack::ice_respon se,
&TestClass_AmiInvokeMethod_CallBack::ice_exception );

proxy->begin_AmiInvokeMethod(cb);
proxy->DirectInvokeMethod();

when AmiInvokeMethod occur exception

class TestClass_AmiInvokeMethod_CallBack : public IceUtil::Shared
{
void ice_exception(const Exception&)
{
proxy = NULL;
printf("proxy = NULL;\n");
}
};

server implement AmiInvokeMethod and DirectInvokeMethod like this

void Crash::TestClassI::AmiInvokeMethod_async(const ::Crash::AMD_TestClass_AmiInvokeMethodPtr& cb, const ::Ice::Current& /*= ::Ice::Current()*/)
{
Sleep(5000);
printf("AmiInvokeMethod_async\n");
cb->ice_exception(Exception());
return ;
}


void Crash::TestClassI::DirectInvokeMethod_async(const ::Crash::AMD_TestClass_DirectInvokeMethodPtr& cb, const ::Ice::Current& /*= ::Ice::Current()*/)
{
Sleep(5000);
printf("DirectInvokeMethod_async\n");
// Invoke ice_exception will cause client crash
cb->ice_exception(Exception());
// But, invoke ice_response not
// cb->ice_response(0);
return;
}

the event occur like this
1.Invoke AmiInvokeMethod
2.Invoke DirectInvokeMethod
3.AmiInvokeMethod return exception, proxy = NULL;
4.DirectInvokeMethod return response(normal) or exception(crash)

I can't understand why it does this. Who can tell me .

I upload my demo as an attachment.

Best regards.

Comments

  • dwaynedwayne St. John's, NewfoundlandMember Dwayne BooneOrganization: ZeroC, Inc.Project: Internet Communications Engine
    Hi,

    Your code is not thread safe. You are setting proxy to NULL in the callback while it is still being explicitly used in the main thread calling DirectInvokeMethod.

    Regards
  • sepcitysepcity Member Daniel YuanOrganization: fsmeetingProject: Video Conference
    dwayne wrote: »
    Hi,

    Your code is not thread safe. You are setting proxy to NULL in the callback while it is still being explicitly used in the main thread calling DirectInvokeMethod.

    Regards

    I understand what you say, But if I change the AmiInvokeMethod's ice_exception call back function like this

    class TestClass_AmiInvokeMethod_CallBack : public IceUtil::Shared
    {
    void ice_exception(const Exception&)
    {
    ic = NULL; // ic is the ice comunicator of proxy
    printf("ic = NULL;\n");
    }
    };

    It doesn't crash. But when does the communicator destroy? (if i invoke ic->destroy() in the ice_exception(), will cause deadlock??)




    The real thing i want to do is , when exception happened, I reconnect the ice server (create a new ice communicator), But at the time asynchronous exception happened, maybe there are some other thread invoke ice synchronous interface, How can I do?


    Best regards.
Sign In or Register to comment.