Sun's XDR routines won't work on Sun machines ...

Sun's XDR routines won't work on Sun machines ...

Post by Frank Hartl » Thu, 10 Sep 1992 22:43:13

... although they do on a NeXT.
Perhaps somebody can see an error in this code.


        BufferSize += 50000;
        Buffer = malloc (BufferSize);
        Offset = strlen (ARCHIVED) + strlen (Description) + 1 + 4;
        sprintf (Buffer, ARCHIVED "%s", Description);
        xdrmem_create (&Stream, Buffer + Offset, BufferSize - Offset, XDR_ENCODE);
        (in another function)
        if (Stream->x_op == XDR_ENCODE) {
                if (*Pointer != NULL) {
                        if (! xdr_bool (Stream, &NonNil))   <=== Bus error
                                return -1;
                        Next = 0;
                        if (DescriptionLoop (
                                Stream, Description, Descriptor, Pointer, &Next)
                            == -1)
                                return -1;

Some more info:
1.      The xdr_bool does the first write to the XDR stream, so it's very
        probable that something's wrong with the stream.
2.      The malloc for Buffer was ok, there should be enough memory for
        the stream.
3.      The Stream and NonNil variables seem to be ok, too.

I'm totally clueless. The routines have been heavily used on a NeXT without
any problem, but on a Sun4 (and IPX) they never make it beyond that point.

Any ideas are greatly apreciated.



Sun's XDR routines won't work on Sun machines ...

Post by Barry Margol » Fri, 11 Sep 1992 01:15:48

>        BufferSize += 50000;
>        Buffer = malloc (BufferSize);
>        Offset = strlen (ARCHIVED) + strlen (Description) + 1 + 4;
>        sprintf (Buffer, ARCHIVED "%s", Description);
>        xdrmem_create (&Stream, Buffer + Offset, BufferSize - Offset, XDR_ENCODE);

Someone just pointed out in comp.sys.sun.<something> that Sun's
implementation of the xdrmem_* functions require the buffer to be
word-aligned, as they make use of the "coincidence" that the XDR
representation of many data types matches the 68000/SPARC representation.
This restriction isn't documented.
Barry Margolin
System Manager, Thinking Machines Corp.


Sun's XDR routines won't work on Sun machines ...

Post by Casper H.S. D » Fri, 11 Sep 1992 22:02:05

>... although they do on a NeXT.
>Perhaps somebody can see an error in this code.

Funny, someone has exactly the same problems as you did, some days ago.

Quote:>        xdrmem_create (&Stream, Buffer + Offset, BufferSize - Offset, XDR_ENCODE);

This call is in error: Offset is not guaranteed to be a multiple of
4 bytes in your code, but the documentation says it should be.
Sun forgot to document that you should properly align the ``Buffer + Offset''
parameter on a 4 byte boundary. The Bus error is an alignment error
(Dbx will tell you as much). NeXTs don't require strict alignment,
but the code will run slower. The culprit is xdrmem_*long where
a char * is cast to a long *. For efficiency's sake, I expect that
Sun will change the documentation, not the code.

                                                |       Casper H.S. Dik


1. sun's netscape 4.5/Sol 7 versus sun's developer site


* Ultra-1 box
* Solaris 7, 64-bit mode. - no patches
* Netscape 4.5 (package from Sun)
* Apache 1.2.4 proxy (http 1.1)

Netscape 4.5 is noticeably less stable on Solaris 7 than on Solaris
2.5.1. This showed up nicely for me on the Solaris Developer site, when
I logged in, went to the "cool demo's" page and attempted to download
'xformat.tar'. Every time the browser crashed. There certainly seems a
problem with some ftp sites also.

Has anyone else noticed this type of problem? I also tried the hotjava
shipped with Sol 7. That fails to log in (the 1.1.5 would work it it had
been shipped inseated of 1.0.3, methinks) because it seems to have
cookie problems. In the end I ftp'ed lynx.


< 1K Download

2. Problems compiling glibc for cross-compilation

3. GPL'ing Solaris won't save SUN

4. Simple but sweet. a.out is not my friend

5. pipe key won't work on a Sun keyboard

6. NFS port and linux

7. HP's STL works with Sun's ProWorks C++ Compiler?

8. Questions about 5.0.2

9. Sun 'find' is missing '-maxdepth'!

10. 'make' won't work w/o '-f Makefile', which sucks.

11. 'init 6' and 'killall' on sun-solaris.

12. 'sh' script spawning Sun 'cmdtool' running program

13. KVM switch with USB for Sun Blade, PC's with Sun Type6?