Archived
This forum has been archived. Please start a new discussion on GitHub.
Bad address exception in IceE 1.3
The following patch addresses the exception:
../../src/TcpTransport/Transceiver.cpp:115: Ice::SocketException: socket exception: Bad address
that occurs intermittently (when the server process is concurrently sending from multiple servants).
Note: The original code fails when the Buffer::i member variable is zero. ConnectionI::sendMessage() sets the Buffer::i member variable to zero when the message is queued.
../../src/TcpTransport/Transceiver.cpp:115: Ice::SocketException: socket exception: Bad address
that occurs intermittently (when the server process is concurrently sending from multiple servants).
[COLOR=#333333][FONT=Consolas][SIZE=14px]--- orig/IceE-1.3.0/cppe/src/IceE/Buffer.cpp 2008-12-18 08:17:40.000000000 +0000[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]+++ patched/IceE-1.3.0/cppe/src/IceE/Buffer.cpp 2015-09-22 00:22:30.929268002 +0000[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]@@ -18,11 +18,23 @@[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px] IceInternal::Buffer::swap(Buffer& other)[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px] {[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px] #ifdef ICE_SMALL_MESSAGE_BUFFER_OPTIMIZATION[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]- Container::difference_type pos = static_cast<int>(i - b.begin());[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]- Container::difference_type otherPos = static_cast<int>(other.i - other.b.begin());[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]+ bool wasThisReset = (0 == i);[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]+ Container::difference_type pos = 0;[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]+ if (b.begin() < i)[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]+ pos = static_cast<Container::difference_type>(i - b.begin());[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]+ bool wasOtherReset = (0 == other.i);[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]+ Container::difference_type otherPos = 0;[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]+ if (other.b.begin() < other.i)[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]+ otherPos = static_cast<Container::difference_type>(other.i - other.b.begin());[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px] b.swap(other.b);[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]- i = b.begin() + otherPos;[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]- other.i = other.b.begin() + pos;[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]+ if (wasOtherReset)[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]+ i = 0;[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]+ else[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]+ i = b.begin() + otherPos;[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]+ if (wasThisReset)[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]+ other.i = 0;[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]+ else[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px]+ other.i = other.b.begin() + pos;[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px] #else[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px] b.swap(other.b);[/SIZE][/FONT][/COLOR] [COLOR=#333333][FONT=Consolas][SIZE=14px] std::swap(i, other.i);[/SIZE][/FONT][/COLOR]
Note: The original code fails when the Buffer::i member variable is zero. ConnectionI::sendMessage() sets the Buffer::i member variable to zero when the message is queued.
0