Home Bug Reports

IcePy segfaults on incorrect router configuration

vsevolodvsevolod Member Vsevolod FedorovOrganization: "NTC Komset"Project: telecom monitoring (ss7,sigtran,etc) software
When calling createObjectAdapterWithRouter method by python program any exception leads to segfault.
import sys, Ice

class Client(Ice.Application):
  def run(self, args):
    ic = self.communicator()
    router = ic.stringToProxy('Glacier2/router:default')
    router = Ice.RouterPrx.uncheckedCast(router)
    adapter = ic.createObjectAdapterWithRouter('TestAdapter', router)

app = Client()
sys.exit(app.main(sys.argv))
$ ./test.py 
Segmentation fault

As I can see from Communicator.cpp source Python global interpreter lock is released when C++ exception is converted to Python. But it is used implicitly by setPythonException function.
AllowThreads allowThreads; // Release Python's global interpreter lock to avoid a potential deadlock.

    assert(self->communicator);
    Ice::ObjectAdapterPtr adapter;
    try
    {
        adapter = (*self->communicator)->createObjectAdapterWithRouter(name, router);
    }
    catch(const Ice::Exception& ex)
    {
        setPythonException(ex);
        return 0;
    }
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb7c986c0 (LWP 32635)]
0xb7eee1cd in PyImport_GetModuleDict () at Python/import.c:363
363             PyInterpreterState *interp = PyThreadState_GET()->interp;
(gdb) bt
#0  0xb7e601cd in PyImport_GetModuleDict () at Python/import.c:363
#1  0xb7a9ad4d in IcePy::lookupType ([email protected]) at Util.cpp:511
#2  0xb7a9c9b2 in IcePy::convertException ([email protected]) at Util.cpp:746
#3  0xb7a9cfba in IcePy::setPythonException ([email protected]) at Util.cpp:796
#4  0xb7a3dd16 in communicatorCreateObjectAdapterWithRouter (self=0x8262420, args=0x8093a6c) at Communicator.cpp:1016
...
Tested on Linux, Ice-3.3.1 and Ice-3.2.1

Comments

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Welcome to the forum!

    I've confirmed this bug. You can fix it by moving the AllowThreads line inside the try block.

    Thanks for bringing this to our attention.

    Regards,
    Mark
Sign In or Register to comment.