Archived

This forum has been archived. Please start a new discussion on GitHub.

Method call results in StackOverflowError

We currently use Ice 3.3.1 for communication from a Java client to a Java server. The application behaves as excepted except when we call a certain method of our Ice interface. This method always throws the following exception:

2009-09-03 21:07:33,984 ERROR: AudioStartThread Ice.SocketException
error = 0
Ice.SocketException
error = 0
at IceInternal.Selector.setInterrupt(Selector.java:347)
at IceInternal.Selector.remove(Selector.java:107)
at IceInternal.ThreadPool.finish(ThreadPool.java:183)
at Ice.ConnectionI.setState(ConnectionI.java:1454)
at Ice.ConnectionI.setState(ConnectionI.java:1351)
at Ice.ConnectionI.sendRequest(ConnectionI.java:383)
at IceInternal.ConnectionRequestHandler.sendRequest(ConnectionRequestHandler.java:36)
at IceInternal.Outgoing.invoke(Outgoing.java:66)
at cctvnet.cif.siteserver._SiteServerSessionDelM.setRemoteControl(_SiteServerSessionDelM.java:1273)
at cctvnet.cif.siteserver.SiteServerSessionPrxHelper.setRemoteControl(SiteServerSessionPrxHelper.java:1879)
at cctvnet.cif.siteserver.SiteServerSessionPrxHelper.setRemoteControl(SiteServerSessionPrxHelper.java:1851)
at com.diligentit.cctvnet.comm.SiteServerSession.setRemoteControl(SiteServerSession.java:319)
at com.diligentit.cctvnet.comm.SiteServerProxy.setRemoteControl(SiteServerProxy.java:278)
at com.diligentit.cctvnet.workplace.model.threads.AudioStartThread.startAudio(AudioStartThread.java:196)
at com.diligentit.cctvnet.workplace.model.threads.AudioStartThread.run(AudioStartThread.java:88)
Caused by: java.nio.channels.ClosedByInterruptException
at java.nio.channels.spi.AbstractInterruptibleChannel.end(Unknown Source)
at sun.nio.ch.SocketChannelImpl.write(Unknown Source)
at sun.nio.ch.SinkChannelImpl.write(Unknown Source)
at IceInternal.Selector.setInterrupt(Selector.java:343)

The interface definition for this method is quite simple:

["ami"] void setRemoteControl(string remoteControlId, bool active) throws cctvnet::cif::common::ObjectNotFoundException;

The log in the client looks as follows but the call does never reach the server:

[ 03.09.09 21:30:08:015 Protocol: sending request
message type = 0 (request)
compression status = 0 (not compressed; do not compress response, if any)
message size = 104
request id = 15
identity = c0:a8:2:24:21932a81:123815de673:-7ffe
facet =
operation = setRemoteControl
mode = 0 (normal)
context = ]

Later we get a stack overflow error (notice, it is a different thread):

Exception in thread "SiteServerMonitor" java.lang.StackOverflowError
at java.util.LinkedList.listIterator(Unknown Source)
at java.util.AbstractList.listIterator(Unknown Source)
at java.util.AbstractSequentialList.iterator(Unknown Source)
at IceInternal.ConnectRequestHandler.flushRequests(ConnectRequestHandler.java:399)
at IceInternal.ConnectRequestHandler.setConnection(ConnectRequestHandler.java:275)
at IceInternal.RoutableReference$3.setConnection(RoutableReference.java:863)
at IceInternal.OutgoingConnectionFactory.create(OutgoingConnectionFactory.java:268)
at IceInternal.RoutableReference.createConnection(RoutableReference.java:848)
at IceInternal.RoutableReference.getConnectionNoRouterInfo(RoutableReference.java:510)
at IceInternal.RoutableReference.getConnection(RoutableReference.java:501)
at IceInternal.ConnectRequestHandler.connect(ConnectRequestHandler.java:41)
at Ice._ObjectDelM.setup(_ObjectDelM.java:275)
at Ice.ObjectPrxHelperBase.createDelegate(ObjectPrxHelperBase.java:1007)
at Ice.ObjectPrxHelperBase.__getDelegate(ObjectPrxHelperBase.java:946)
at IceInternal.OutgoingAsync.__send(OutgoingAsync.java:298)
at Ice.ObjectPrxHelperBase.__handleExceptionWrapperRelaxed(ObjectPrxHelperBase.java:911)
at IceInternal.OutgoingAsync.handleException(OutgoingAsync.java:406)
at IceInternal.OutgoingAsync.__send(OutgoingAsync.java:303)
at Ice.ObjectPrxHelperBase.__handleExceptionWrapperRelaxed(ObjectPrxHelperBase.java:911)
at IceInternal.OutgoingAsync.handleException(OutgoingAsync.java:406)
at IceInternal.OutgoingAsync.__send(OutgoingAsync.java:303)
at Ice.ObjectPrxHelperBase.__handleExceptionWrapperRelaxed(ObjectPrxHelperBase.java:911)
at IceInternal.OutgoingAsync.handleException(OutgoingAsync.java:406)
at IceInternal.OutgoingAsync.__send(OutgoingAsync.java:303)
at Ice.ObjectPrxHelperBase.__handleExceptionWrapperRelaxed(ObjectPrxHelperBase.java:911)
at IceInternal.OutgoingAsync.handleException(OutgoingAsync.java:406)
at IceInternal.OutgoingAsync.__send(OutgoingAsync.java:303)
...
at Ice.ObjectPrxHelperBase.__handleExceptionWrapperRelaxed(ObjectPrxHelperBase.java:911)
at IceInternal.OutgoingAsync.handleException(OutgoingAsync.java:406)
at IceInternal.OutgoingAsync.__send(OutgoingAsync.java:303)
at Ice.ObjectPrxHelperBase.__handleExceptionWrapperRelaxed(ObjectPrxHelperBase.java:911)

When we call the same method setRemoteControl() from another Java client there is no exception. Strange. Any hints what could be wrong with this call or what we could investigate? It should not be a problem that this call is made from a different thread than the one that initialized the Ice runtime, isnt't it?

Regards, Stephan

Comments

  • benoit
    benoit Rennes, France
    Hi Stephan,

    Yes, it's fine to make Ice calls from other threads than the one that created the Ice communicator.

    Here, the Ice runtime encounters an un-expected error condition and doesn't behave very well after that. I believe the problem comes from the following:
    Caused by: java.nio.channels.ClosedByInterruptException
    at java.nio.channels.spi.AbstractInterruptibleChannel .end(Unknown Source)
    at sun.nio.ch.SocketChannelImpl.write(Unknown Source)
    at sun.nio.ch.SinkChannelImpl.write(Unknown Source)
    at IceInternal.Selector.setInterrupt(Selector.java:34 3)
    

    The pipe used by the Ice thread pool selector is closed, this shouldn't happen. The ClosedByInterruptException indicates that the pipe has been closed because a thread using the pipe has been interrupted. So the most likely reason is that you use the Java Thread interrupt() method in your application to interrupt threads which are using the Ice runtime. Is this possible?

    Ice currently doesn't support Java thread interrupts so you shouldn't use thread interrupts with threads that are using the Ice runtime.

    Cheers,
    Benoit.
  • Hi Benoit

    I indeed found a call of Thread.interrupt() for the thread mentioned above. When I removed it, everything worked fine.

    Thanks a lot!
    Stephan