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

buffer corruption using string as a parameter


i'm using ICE v3.4.2 with a Macintosh client and Windows server with C++ as the implementation language on both platforms.

we want to transmit variable length log messages from the client to the server. for this i defined in the slice file a function void log(string msg)

a large percentage of the time there seems to be buffer corruption in the string message received by the Windows server software (the message lengths are ok, though).
for test/debug purposes, we also log the messages sent to the client hard drive.

the corruption does not appear at random offsets within the corrupted messages.
for example, we frequently see a (valid) log message of the form:
"2012-05-23 11:06:10: CAMAC Module Lecroy Memory Module: setting baseAddress to 10067"

however, messages are sometimes received in the form:
"2012-05-23 11:05:57: CAMAC Module Lecroy Memory Module: setting baseAddres"
(with the remaining bytes garbage)

if i use exercise the code by using the Windows machine as a client and the Macintosh as a server, the log() function works as expected 100% of the time.

i couldn't find any demo using a string as a parameter. also, i couldn't find any relevant previous post.

any suggestions?

thanks in advance.


  • mes
    mes California
    Hi Keith,

    Welcome to the forum.

    Can you also tell us which OS and compiler versions you are using? And are you using our binary distributions for Mac and Windows, or did you build them from source yourself?

    The first thing to determine is where the message is being corrupted: in the Mac client, or in the Windows server? Here's what I suggest: build a debug version of your Windows server, start it in the debugger (or attach to the process later), and set a breakpoint in the skeleton code. Specifically, for an operation named log in interface Logger, you would set a breakpoint in the method Logger::___log.

    This method will contain code that looks like this:
    ::IceInternal::BasicStream* __is =;
    ::std::string msg;
    __is->endReadEncaps(); // **

    Set a breakpoint on the line marked with **. After the break, examine the value of msg. You could also look directly into the message buffer itself by examining the members of __is. If the string is garbled here, that's a strong indication that it is being corrupted in the client.

    Of course, I also have to recommend the use of a memory-checking tool such as Purify to verify that other unrelated components of your server aren't causing the corruption.

    Finally, if you still have no luck tracking this down, and can put together a small example that reproduces the problem, we'd be happy to give it a look.

  • mes
    mes California
    One additional thought... If it's too tedious to use the debugger to check each invocation for a corrupted message, you could also modify the generated code to add a line that prints out the contents of the msg value, or even dumps the original message buffer (hint: the member __is->b can be used like a std::vector).

  • thanks for your suggestions.
    we found the problem in another vendor's code.

    btw, is there any documentation on how to build from source using Visual Studio 2008?
  • xdm
    xdm La Coruña, Spain
    The build process is documented in "cpp/INSTALL.WINDOWS", this file is part of the source distribution.