Archived
This forum has been archived. Please start a new discussion on GitHub.
IcePy segfaults on incorrect router configuration
When calling createObjectAdapterWithRouter method by python program any exception leads to segfault.
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.
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 (typeName=@0xbf93f860) at Util.cpp:511 #2 0xb7a9c9b2 in IcePy::convertException (ex=@0x8120dc8) at Util.cpp:746 #3 0xb7a9cfba in IcePy::setPythonException (ex=@0x8120dc8) 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
0
Comments
-
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,
Mark0