Skip navigation.
 
mlRe: Distributed objects: can't send simple C struct by value
FROM : Michael Heins
DATE : Sat Oct 30 16:28:41 2004

On Oct 30, 2004, at 3:25 AM, Wade Tregaskis wrote:

>> struct _Msg {
>>     int a_fill;
>>     char name[64];
>>     int b_fill;
>> };
>>
>> The problem seems to be that the struct is not getting encoded
>> properly in the sender.  The encoded object description appears to be
>> correct, and 'a_fill' and the first part of 'name' appears to be
>> correct, but the remainder of the structure is garbage.

>
> Define "first part of 'name'"?


Here is a dump of the struct in the sender just before sending:

  BFFFE990: AAAAAAAA 54686973  20697320 6D792074  ....This is my t
  BFFFE9A0: 65737420 73747269  6E672077 68696368  est string which
  BFFFE9B0: 20676574 73207061  72746C79 20776970  gets partly wip
  BFFFE9C0: 6564206F 75742E00  00000000 00000000  ed out..........
  BFFFE9D0: 00000000 BBBBBBBB                    ........

Here it is in the receiver:

  BFFFE650: AAAAAAAA 54686973  20697320 6D792074  ....This is my t
  BFFFE660: 65737420 73747269  6E672077 A0A03CD4  est string w..<.
  BFFFE670: 00528BB0 BFFFE6F0  A0A01234 909FA88C  .R.........4....
  BFFFE680: BFFFEB00 24022244  909FABF0 02800000  ....$."D........
  BFFFE690: 00000020 00000018                    ... ....

If I set up authenticationDataForComponents / authenticateComponents
delegates on both ends and look at the encoded data in the sender just
after encoding the corruption has already happened.  I suspect that
this has something to do with the way structures are passed by value by
the compiler -- I believe that the first part of structs are passed in
registers, and the remainder on the stack.  I'm guessing that the
encoder is not properly taking this into account.

You are correct about byteswapping -- encoded int's etc. do get
byteswapped (though that won't be obvious with the test contents I
chose above).

Michael Heins AA7XY

Related mailsAuthorDate
mlDistributed objects: can't send simple C struct by value Michael Heins Oct 30, 10:16
mlRe: Distributed objects: can't send simple C struct by value Wade Tregaskis Oct 30, 11:25
mlRe: Distributed objects: can't send simple C struct by value Michael Heins Oct 30, 16:28
mlRe: Distributed objects: can't send simple C struct by value Wade Tregaskis Oct 30, 17:21
mlRe: Distributed objects: can't send simple C struct by value Michael Heins Oct 30, 18:14
mlRe: Distributed objects: can't send simple C struct by value Jim Correia Oct 30, 19:46
mlRe: Distributed objects: can't send simple C struct by value Michael Heins Oct 30, 19:59
mlRe: Distributed objects: can't send simple C struct by value Michael Heins Oct 31, 17:53