Ice 3.5.1: compatibility with Intel C++ 2015

alexmnazarenkoalexmnazarenko Member Alexey NazarenkoOrganization: DATADVANCEProject: Workflow management system
Hi. We've managed to build a working version of Ice with intel compiler (On Win x64). It works with our (quite complex) app, so hopefully build is correct.

However, it required patch to Ice code which took a while to figure out. Everything just froze on connection establishment. Patch seems to be correct and harmless, so we suggest it to developers to apply in some later version to save trouble to other desperate Intel C++ users.

The problem is in subtle difference in overload selection. In a code:
#include <iostream>

struct T {}; 
struct PtrT { PtrT(T*) {} };

void f(bool&) { std::cout << "FAIL - bool" << std::endl; }
void f(PtrT) { std::cout << "OK - PtrT" << std::endl; }

int main() {
  f(new T);
}

Intel selects "bool&" overload without a warning. Ice source contains few overloads of this type (e.g. IceInternal::OutgoingConnectionFactory::create, Ice::Handle is similar to PtrT in example). The result is awful - pointer to callback gets casted to bool, callback is lost, application freezes.

Patch text:
--- cpp/src/Ice/Reference.cpp
+++ cpp/src/Ice/Reference.cpp
@@ -1666,7 +1666,7 @@

             vector<EndpointIPtr> endpts = endpoints;
             _reference->applyOverrides(endpts);
-            _reference->createConnection(endpts, new Callback2(_reference, _callback, cached));
+            _reference->createConnection(endpts, GetConnectionCallbackPtr(new Callback2(_reference, _callback, cached)));
         }

         virtual void
@@ -1695,7 +1695,7 @@
     if(_locatorInfo)
     {
         RoutableReference* self = const_cast<RoutableReference*>(this);
-        _locatorInfo->getEndpoints(self, _locatorCacheTimeout, new Callback(self, callback));
+        _locatorInfo->getEndpoints(self, _locatorCacheTimeout, LocatorInfo::GetEndpointsCallbackPtr(new Callback(self, callback)));
     }
     else
     {
@@ -1829,7 +1829,7 @@
         // Get an existing connection or create one if there's no
         // existing connection to one of the given endpoints.
         //
-        factory->create(endpoints, false, getEndpointSelection(), new CB1(_routerInfo, callback));
+        factory->create(endpoints, false, getEndpointSelection(), OutgoingConnectionFactory::CreateConnectionCallbackPtr(new CB1(_routerInfo, callback)));
         return;
     }
     else
@@ -1904,7 +1904,7 @@
         vector<EndpointIPtr> endpt;
         endpt.push_back(endpoints[0]);
         RoutableReference* self = const_cast<RoutableReference*>(this);
-        factory->create(endpt, true, getEndpointSelection(), new CB2(self, endpoints, callback));
+        factory->create(endpt, true, getEndpointSelection(), OutgoingConnectionFactory::CreateConnectionCallbackPtr(new CB2(self, endpoints, callback)));
         return;
     }
 }

Comments

  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Alexey,

    Thank you for this patch!

    Could you please submit a pull request on GitHub, for the 3.5 branch or for the master branch (which will soon be 3.6)?

    See https://github.com/zeroc-ice/ice/blob/master/CONTRIBUTING.md

    Best regards,
    Bernard
  • alexmnazarenkoalexmnazarenko Member Alexey NazarenkoOrganization: DATADVANCEProject: Workflow management system
    Hi Bernard,

    I read the contibution procedure, and it's quite scary. Mailing a signed contibutor agreement seems like an overkill for this little patch :(

    I may do it in future, but I hoped that simpler patches could be submitted through forum (to be applied by active developers).
  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Alexey,

    You can send us a signed copy of this contributor agreement by email (just scan it). You can also mail it if you prefer, but it's not required.

    And we need this signed contributor agreement only once - before your first contribution.

    All the best,
    Bernard
  • alexmnazarenkoalexmnazarenko Member Alexey NazarenkoOrganization: DATADVANCEProject: Workflow management system
    Hi Bernard,

    Understood. E-mail is fine ) I will submit pull request soon.
  • alexmnazarenkoalexmnazarenko Member Alexey NazarenkoOrganization: DATADVANCEProject: Workflow management system
Sign In or Register to comment.