[omniORB] Bad magic in CORBA::Environment object.
Alex Tingle
alex.omniorb at firetree.net
Sat Apr 10 18:09:02 BST 2004
Hello,
The Dynamic Invokation Interface seems to (very occasionally) generate
some bad values. I suspect that there is a subtle race condition
somewhere in the omniORB library code and I'd appreciate some help
trying to find it.
Here's a code fragment that illustrates the problem (The full method is
in the attachment):
if(!CORBA::is_nil(_req) && _req->poll_response())
{
CORBA::Environment_var env=_req->env();
if(!CORBA::Environment::PR_is_valid(env.in()))
{
A: cerr<<"EEK!!"<<endl;
}
B: else if(!CORBA::is_nil(env) && env->exception())
{
...
Without the check for PR_is_valid(), the program core dumps at B).
is_nil() returns false (as it always does when the object has bad
magic), and then the call to environment() causes a SEGV.
With the check for PR_is_valid(), the error messages is printed out but
the program continues OK.
This error is very rare. My test setup has three threads running in
parallel, all calling this DII method (on different data), in total it
is called ~500 times per second. Perhaps one call in every 200,000
exhibits the error.
Duncan, perhaps you could give me an idea where to start looking for
this problem?
One further question: Why does CORBA::is_nil(x) return `false' when x
has bad magic? I would have thought that `true' would have been a safer
result.
regards,
-Alex Tingle
-------------- next part --------------
bool ProxyPushSupplier_i::trigger()
{
if(!CORBA::is_nil(_req) && _req->poll_response()) // response has arrived
{
CORBA::Environment_var env=_req->env();
if(!CORBA::Environment::PR_is_valid(env.in()))
{
DB(1,"ProxyPushSupplier got response with invalid Environment!"
"\n CORBA::Environment::PR_is_valid(env.in())==0"
"\n env=="<<(long)(env.in()));
}
else if(!CORBA::is_nil(env) && env->exception())
{
CORBA::Exception* ex =env->exception(); // No need to free exception.
DB(1,"ProxyPushSupplier got exception"
IFELSE_OMNIORB4(": "<<ex->_name(),) );
_req=CORBA::Request::_nil();
_target=CosEventComm::PushConsumer::_nil(); // disconnected.
eraseKey("ConsumerAdmin/ProxyPushSupplier");
deactivateObject();
return false; // No more work to do
}
_req=CORBA::Request::_nil();
}
if(CORBA::is_nil(_req) && !CORBA::is_nil(_target) && moreEvents())
{
_req=_target->_request("push");
_req->add_in_arg() <<= *(nextEvent());
_req->send_deferred();
}
return !CORBA::is_nil(_req); // More work to do, if _req NOT nil.
}
More information about the omniORB-list
mailing list