[M3devel] Juno (X) networking problem on AMD64_FREEBSD

Mika Nystrom mika at async.caltech.edu
Mon Jan 12 10:06:30 CET 2009


Jay,

I think the problem here is actually in the caller.  Why does a
caller need "GetHostAddr()"?  It is probably doing this for the
purpose of calling listen() or some such thing.  What the caller
probably *really* wants is INADDR_ANY, and not the IP address of
some arbitrarily chosen interface on the host.

I'm guessing it works on the Mac because the Mac libraries do
something complicated when you ask for the host's name (i.e., they
somehow generate a hostname that always maps to the IP address of
an interface on the computer).

    Mika

Jay writes:
>--_b00371fe-730b-4981-9051-a874361296d7_
>Content-Type: text/plain; charset="iso-8859-1"
>Content-Transfer-Encoding: quoted-printable
>
>
>Do you know the right way?
>=20
>PPC_LINUX "just worked"=2C and I can check Solaris and Darwin.
>=20
>I don't want to edit /etc/hosts -- I use DHCP.
>Though DHCP has been bothering me -- only for some of my machines do names =
>resolve=2C so I end using IP addresses=2C which change sometimes=2C and I l=
>oop over them running ssh to all of them and "see what I get"=2C not ideal.
>=20
> - Jay> To: jay.krell at cornell.edu> Date: Sun=2C 11 Jan 2009 08:02:18 -0800>=
> From: mika at async.caltech.edu> CC: m3devel at elegosoft.com> Subject: Re: [M3d=
>evel] Juno (X) networking problem on AMD64_FREEBSD> > This is a screwy thin=
>g in Modula-3. A bug I would call it.> > I've noticed a lot of networking M=
>3 programs don't work right unless> the return value of Unix's "hostname" m=
>aps to a real IP address via> gethostbyname. I accomplish it in practice by=
> adding my hostname> to /etc/hosts.> > This is obviously not the right way =
>to fix it... > > Mika> > Jay writes:> >--_9e67232c-a064-417d-879e-227a77e31=
>0f9_> >Content-Type: text/plain=3B charset=3D"iso-8859-1"> >Content-Transfe=
>r-Encoding: quoted-printable> >> >> >Hi. Unix network programming question.=
>.> >AMD64_FREEBSD:> >$DISPLAY is set to point back to Cygwin host.It works =
>for PPC_LINUX.> >[jay at fbsdamd64a /cm3/bin]$ ./Juno> >****** runtime error:*=
>** Exception "IPError.FatalError" not in RAISES li=3D> >st*** file "../src/=
>common/IPError.m3"=3D2C line 27***> >Abort trap: 6 (core dumped)[jay at fbsdam=
>d64a /cm3/bin]$> >IP.m3:> >=3D20> >PROCEDURE GetHostAddr(): Address =3D3D V=
>AR hname: ARRAY [0..255] OF CHAR=3D3B =3D> > BEGIN LOCK mu DO IF Unix.getho=
>stname(ADR(hname[0])=3D2C BYTESIZE(hna=3D> >me)) # 0 THEN IPError.Die ()=3D=
>3B END=3D3B VAR h :=3D3D Unetdb.g=3D> >ethostbyname(ADR(hname[0]))=3D3B BEG=
>IN IF h =3D3D NIL THEN IPError.Die()=3D> >=3D3B END=3D3B RETURN GetAddress(=
>h)=3D3B END=3D3B END=3D3B END GetHos=3D> >tAddr=3D3B> >PROCEDURE GetAddress=
> (ent: Unetdb.struct_hostent_star): Address =3D3D VAR ua=3D> >: Uin.struct_=
>in_addr=3D3B BEGIN <* ASSERT ent.h_length <=3D3D BYTESIZE(Addr=3D> >ess) *>=
> ua :=3D3D LOOPHOLE(ent.h_addr_list=3D2C UNTRACED =3D> >REF UNTRACED REF Ui=
>n.struct_in_addr)^^=3D3B RETURN LOOPHOLE(ua.s_addr=3D2C A=3D> >ddress)=3D3B=
> END GetAddress=3D3B> >=3D20> >gethostbyname is failing.> >=3D20> >Analogou=
>s C code also fails:> >=3D20> >[jay at fbsdamd64a /cm3/bin]$ cat ~/5.c#include=
> <assert.h>#include <netdb.h>#i=3D> >nclude <stdio.h>#include <errno.h>type=
>def struct hostent hostent_t=3D3B> >=3D20> >int main(){ char hostname[200]=
>=3D3B hostent_t* h=3D3B int i=3D3B> > i =3D3D gethostname(hostname=3D2C 200=
>)=3D3B assert(i =3D3D=3D3D 0)=3D3B printf("hostna=3D> >me: %s\n"=3D2C hostn=
>ame)=3D3B h =3D3D gethostbyname(hostname)=3D3B herror("foo")=3D3B=3D> > pri=
>ntf("%p %d %d\n"=3D2C h=3D2C errno=3D2C h_errno)=3D3B assert(h)=3D3B return=
> 0=3D3B}> >=3D20> >herror says "unknown host".> >Stack is:> > at ../src/run=
>time/ex_frame/RTExFrame.m3:58#13 0x0000000801a7f2b3 in RTH=3D> >ooks__Raise=
> (M3_AJWxb1_ex=3D3DError accessing memory address 0x8000ffffd278: =3D> >Bad=
> address.) at ../src/runtime/common/RTHooks.m3:79#14 0x000000080169c8=3D> >=
>d3 in IPError__Die () at ../src/common/IPError.m3:27#15 0x0000000801698a3e =
>=3D> >in IP__GetHostAddr (M3_BCxjPn__result=3D3DError accessing memory addr=
>ess 0x80=3D> >00ffffd338: Bad address.) at ../src/POSIX/IP.m3:82#16 0x00000=
>008012133d0=3D> > in XSharedMem__SameHost (M3_AQuuui_trsl=3D3DError accessi=
>ng memory address 0=3D> >x8000ffffd4d8: Bad address.) at ../src/xvbt/XShare=
>dMem.m3:96#17 0x000000=3D> >0801212ab7 in XSharedMem__InitXClient (M3_AQuuu=
>i_v=3D3DError accessing memory=3D> > address 0x8000ffffd648: Bad address.) =
>at ../src/xvbt/XSharedMem.m3:29#1=3D> >8 0x0000000801211819 in XExtensions_=
>_InitXClient (M3_AQuuui_xclient=3D3DError=3D> > accessing memory address 0x=
>8000ffffd7f8: Bad address.) at ../src/xvbt/X=3D> >Extensions.m3:14#19 0x000=
>00008012467a4 in XClientF__Connect (M3_Bd56fi_inst=3D> >=3D3D0x1879b=3D2C M=
>3_AQuuui_trsl=3D3D0x6) at ../src/xvbt/XClientF.m3:583---Typ=3D> >e <return>=
> to continue=3D2C or q <return> to quit---(More stack frames follow=3D> >..=
>.)(gdb)> >(* return TRUE if server and client are on same host *)PROCEDURE =
>SameHost (=3D> >trsl: XClient.T): BOOLEAN =3D3D VAR display :=3D3D DisplayH=
>=3D> >ost(trsl)=3D3B displayAddr: IP.Address=3D3B BEGIN IF display =3D3D NI=
>L THE=3D> >N RETURN TRUE=3D3B END=3D3B> > TRY IF NOT IP.GetHostByName(displ=
>ay=3D2C displayAddr) THEN RETURN FA=3D> >LSE=3D3B END=3D3B RETURN displayAd=
>dr =3D3D IP.GetHostAddr()=3D3B EXCEPT =3D> >| IP.Error =3D3D> RETURN FALSE=
>=3D3B END=3D3B END SameHost=3D3B> >=3D20> >Thoughts?> >=3D20> >Perhaps my n=
>etwork isn't setup well=3D2C like I should add the local machine =3D> >to /=
>etc/hosts.I think this can be made to fail gracefully though.It seems l=3D>=
> >ike it has nothing to do with AMD64_FREEBSD=3D2C but could have to do wit=
>h Fr=3D> >eeBSD.> >=3D20> >Seems like SocketPosix has nearly the exact same=
> code but appearsmore forgi=3D> >ving.. IOError instead of Fatal?> >=3D20> =
>>SocketPosix.m3:> >=3D20> >PROCEDURE GetHostAddr (): Address RAISES {OSErro=
>r.E} =3D3D VAR host : AR=3D> >RAY [0..255] OF CHAR=3D3B info : Unetdb.struc=
>t_hostent_star=3D3B ua : U=3D> >in.struct_in_addr=3D3B BEGIN IF Unix.gethos=
>tname (ADR (host[0])=3D2C BYTESI=3D> >ZE (host)) # 0 THEN IOError (Unexpect=
>ed)=3D3B END=3D3B> > info :=3D3D Unetdb.gethostbyname (ADR (host[0]))=3D3B =
>IF info =3D3D NIL TH=3D> >EN IOError (Unexpected)=3D3B END=3D3B <* ASSERT i=
>nfo.h_length <=3D3D BYTESIZE =3D> >(Address) *>> > ua :=3D3D LOOPHOLE(info.=
>h_addr_list=3D2C UNTRACED REF UNT=3D> >RACED REF Uin.struct_in_addr)^^=3D3B=
> RETURN LOOPHOLE (ua.s_addr=3D2C Address=3D> >)=3D3B END GetHostAddr=3D3B> =
>>=3D20> >=3D20> >It is again disappointing to see such code duplication.> >=
>=3D20> >=3D20> >I guess SameHost can duplicate the logic to predict the err=
>or state and ret=3D> >urn false upon error?> >Duplicating the logic for a t=
>hird time. :(> >=3D20> > - Jay=3D> >> >--_9e67232c-a064-417d-879e-227a77e31=
>0f9_> >Content-Type: text/html=3B charset=3D"iso-8859-1"> >Content-Transfer=
>-Encoding: quoted-printable> >> ><html>> ><head>> ><style>> >.hmmessage P> =
>>{> >margin:0px=3D3B> >padding:0px> >}> >body.hmmessage> >{> >font-size: 10=
>pt=3D3B> >font-family:Verdana> >}> ></style>> ></head>> ><body class=3D3D'h=
>mmessage'>> >Hi. Unix network programming question..<BR>> ><BR>AMD64_FREEBS=
>D:<BR>> ><BR>$DISPLAY is set to point back to Cygwin host.<BR>It works for =
>PPC_LINUX=3D> >.<BR>> ><BR>[jay at fbsdamd64a /cm3/bin]$ ./Juno<BR>> ><BR>***<=
>BR>*** runtime error:<BR>***&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B Exception "IPE=
>=3D> >rror.FatalError" not in RAISES list<BR>***&nbsp=3D3B&nbsp=3D3B&nbsp=
>=3D3B file "..=3D> >/src/common/IPError.m3"=3D2C line 27<BR>***<BR>> ><BR>A=
>bort trap: 6 (core dumped)<BR>[jay at fbsdamd64a /cm3/bin]$<BR>> ><BR>IP.m3:<B=
>R>> >&nbsp=3D3B<BR>> >PROCEDURE GetHostAddr(): Address =3D3D<BR>&nbsp=3D3B =
>VAR hname: ARRAY [0..255] =3D> OF CHAR=3D3B<BR>&nbsp=3D3B BEGIN<BR>&nbsp=3D=
>3B&nbsp=3D3B&nbsp=3D3B LOCK mu DO<BR>&nbs=3D> >p=3D3B&nbsp=3D3B&nbsp=3D3B&n=
>bsp=3D3B&nbsp=3D3B IF Unix.gethostname(ADR(hname[0])=3D2C B=3D> >YTESIZE(hn=
>ame)) # 0 THEN<BR>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=
>=3D> >=3D3B&nbsp=3D3B IPError.Die ()=3D3B<BR>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B=
>&nbsp=3D3B&nbsp=3D3B E=3D> >ND=3D3B<BR>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=
>=3D3B&nbsp=3D3B VAR h :=3D3D Unetdb.gethost=3D> >byname(ADR(hname[0]))=3D3B=
> BEGIN<BR>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&=3D> >nbsp=3D3=
>B&nbsp=3D3B IF h =3D3D NIL THEN IPError.Die()=3D3B END=3D3B<BR>&nbsp=3D3B&n=
>bsp=3D> >=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B RETURN Get=
>Address(h)=3D3B<BR>&nbs=3D> >p=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B=
> END=3D3B<BR>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B END=3D> >=3D3B<BR>&nbsp=3D3B EN=
>D GetHostAddr=3D3B<BR>> ><BR>PROCEDURE GetAddress (ent: Unetdb.struct_hoste=
>nt_star): Address =3D3D<BR>=3D> >&nbsp=3D3B VAR ua: Uin.struct_in_addr=3D3B=
><BR>&nbsp=3D3B BEGIN<BR>&nbsp=3D3B&nbsp=3D> >=3D3B&nbsp=3D3B &lt=3D3B* ASSE=
>RT ent.h_length &lt=3D3B=3D3D BYTESIZE(Address) *&gt=3D3B=3D> ><BR>&nbsp=3D=
>3B&nbsp=3D3B&nbsp=3D3B ua :=3D3D LOOPHOLE(ent.h_addr_list=3D2C<BR>&nbsp=3D>=
> >=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D=
>3B&nbsp=3D3B&nbsp=3D3B=3D> >&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=
>=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B UN=3D> >TRACED REF UNTRACED R=
>EF Uin.struct_in_addr)^^=3D3B<BR>&nbsp=3D3B&nbsp=3D3B&nbsp=3D> >=3D3B RETUR=
>N LOOPHOLE(ua.s_addr=3D2C Address)=3D3B<BR>&nbsp=3D3B END GetAddress=3D3B<=
>=3D> >BR>> >&nbsp=3D3B<BR>> >gethostbyname is failing.<BR>> ><BR>&nbsp=3D3B=
><BR>> >Analogous C code also fails:<BR>> >&nbsp=3D3B<BR>> ><BR>[jay at fbsdamd=
>64a /cm3/bin]$ cat ~/5.c<BR>#include &lt=3D3Bassert.h&gt=3D3B<B=3D> >R>#inc=
>lude &lt=3D3Bnetdb.h&gt=3D3B<BR>#include &lt=3D3Bstdio.h&gt=3D3B<BR>#includ=
>e =3D> >&lt=3D3Berrno.h&gt=3D3B<BR>typedef struct hostent hostent_t=3D3B<BR=
>>> >&nbsp=3D3B<BR>> >int main()<BR>{<BR>&nbsp=3D3Bchar hostname[200]=3D3B<B=
>R>&nbsp=3D3Bhostent_t* h=3D3B=3D> ><BR>&nbsp=3D3Bint i=3D3B<BR>> >&nbsp=3D3=
>Bi =3D3D gethostname(hostname=3D2C 200)=3D3B<BR>&nbsp=3D3Bassert(i =3D3D=3D=
>3D 0)=3D> >=3D3B<BR>&nbsp=3D3Bprintf("hostname: %s\n"=3D2C hostname)=3D3B<B=
>R>&nbsp=3D3Bh =3D3D get=3D> >hostbyname(hostname)=3D3B<BR>&nbsp=3D3Bherror(=
>"foo")=3D3B<BR>&nbsp=3D3Bprintf("%p %=3D> >d %d\n"=3D2C h=3D2C errno=3D2C h=
>_errno)=3D3B<BR>&nbsp=3D3Bassert(h)=3D3B<BR>&nbsp=3D3Bret=3D> >urn 0=3D3B<B=
>R>}<BR>> >&nbsp=3D3B<BR>> >herror says "unknown host".<BR>> ><BR>Stack is:<=
>BR>> >&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B at ../src/runtime/ex_frame/RTExFrame.m=
>3:58<BR>#13 =3D> >0x0000000801a7f2b3 in RTHooks__Raise (M3_AJWxb1_ex=3D3DEr=
>ror accessing memory=3D> > ad<BR>dress 0x8000ffffd278: Bad address.<BR>)<BR=
>>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B =3D> >at ../src/runtime/common/RTHooks.m3:7=
>9<BR>#14 0x000000080169c8d3 in IPError=3D> >__Die () at ../src/common/IPErr=
>or.m3:27<BR>#15 0x0000000801698a3e in IP__Ge=3D> >tHostAddr (M3_BCxjPn__res=
ult=3D3DError accessing mem<BR>ory address 0x8000fff=3D> >fd338: Bad addres=
>s.<BR>)<BR>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B at ../src/POSIX/IP.m3:=3D> >82<BR=
>>#16 0x00000008012133d0 in XSharedMem__SameHost (M3_AQuuui_trsl=3D3DErro=3D=
>> >r accessing m<BR>emory address 0x8000ffffd4d8: Bad address.<BR>)<BR>&nbs=
>p=3D> >=3D3B&nbsp=3D3B&nbsp=3D3B at ../src/xvbt/XSharedMem.m3:96<BR>#17 0x0=
>000000801212a=3D> >b7 in XSharedMem__InitXClient (M3_AQuuui_v=3D3DError acc=
>essing m<BR>emory add=3D> >ress 0x8000ffffd648: Bad address.<BR>)<BR>&nbsp=
>=3D3B&nbsp=3D3B&nbsp=3D3B at ../sr=3D> >c/xvbt/XSharedMem.m3:29<BR>#18 0x00=
>00000801211819 in XExtensions__InitXClie=3D> >nt (M3_AQuuui_xclient=3D3DErr=
>or acce<BR>ssing memory address 0x8000ffffd7f8: =3D> >Bad address.<BR>)<BR>=
>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B at ../src/xvbt/XExtensions.m3=3D> >:14<BR>#1=
>9 0x00000008012467a4 in XClientF__Connect (M3_Bd56fi_inst=3D3D0x1879=3D> >b=
>=3D2C<BR>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B M3_AQuuui_trsl=3D3D0x6) at ../src/x=
>vbt/XClie=3D> >ntF.m3:583<BR>---Type &lt=3D3Breturn&gt=3D3B to continue=3D2=
>C or q &lt=3D3Breturn&g=3D> >t=3D3B to quit---<BR>(More stack frames follow=
>...)<BR>(gdb)<BR>> ><BR>(* return TRUE if server and client are on same hos=
>t *)<BR>PROCEDURE Sa=3D> >meHost (trsl: XClient.T): BOOLEAN =3D3D<BR>&nbsp=
>=3D3B VAR<BR>&nbsp=3D3B&nbsp=3D3B&n=3D> >bsp=3D3B display&nbsp=3D3B&nbsp=3D=
>3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D> >=3D3B&nbsp=
>=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B=
 :=3D3D Di=3D> >splayHost(trsl)=3D3B<BR>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B disp=
>layAddr: IP.Address=3D3B<B=3D> >R>&nbsp=3D3B BEGIN<BR>&nbsp=3D3B&nbsp=3D3B&=
>nbsp=3D3B IF display =3D3D NIL THEN RETURN=3D> > TRUE=3D3B END=3D3B<BR>> >&=
>nbsp=3D3B&nbsp=3D3B&nbsp=3D3B TRY<BR>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D=
>3B&nbsp=3D3B IF=3D> > NOT IP.GetHostByName(display=3D2C displayAddr) THEN R=
>ETURN FALSE=3D3B END=3D3B<B=3D> >R>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B=
>&nbsp=3D3B RETURN displayAddr =3D3D IP.GetHos=3D> >tAddr()=3D3B<BR>&nbsp=3D=
>3B&nbsp=3D3B&nbsp=3D3B EXCEPT<BR>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B |=3D> > IP.=
>Error =3D3D&gt=3D3B RETURN FALSE=3D3B<BR>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B END=
>=3D3B<BR>&=3D> >nbsp=3D3B END SameHost=3D3B<BR>> >&nbsp=3D3B<BR>> >Thoughts=
>?<BR>> >&nbsp=3D3B<BR>> ><BR>Perhaps my network isn't setup well=3D2C like =
>I should add the local mach=3D> >ine to /etc/hosts.<BR>I think this can be =
>made to fail gracefully though.<B=3D> >R>It seems like it has nothing to do=
> with AMD64_FREEBSD=3D2C but could have t=3D> >o do with FreeBSD.<BR>> ><BR=
>>&nbsp=3D3B<BR>> >Seems like SocketPosix has nearly the exact same code but=
> appears<BR>more f=3D> >orgiving.. IOError instead of Fatal?<BR>> >&nbsp=3D=
>3B<BR>> ><BR>SocketPosix.m3:<BR>> >&nbsp=3D3B<BR>> ><BR>PROCEDURE GetHostAd=
>dr (): Address<BR>&nbsp=3D3B RAISES {OSError.E} =3D3D<BR=3D> >>&nbsp=3D3B V=
>AR<BR>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B host : ARRAY [0..255] OF CHAR=3D3B<=3D=
>> >BR>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B info : Unetdb.struct_hostent_star=3D3B=
><BR>&nbsp=3D> >=3D3B&nbsp=3D3B&nbsp=3D3B ua&nbsp=3D3B&nbsp=3D3B : Uin.struc=
>t_in_addr=3D3B<BR>&nbsp=3D3B =3D> >BEGIN<BR>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B =
>IF Unix.gethostname (ADR (host[0])=3D2C BYT=3D> >ESIZE (host)) # 0 THEN<BR>=
>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B IOError =3D> >(Unexpecte=
>d)=3D3B<BR>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B END=3D3B<BR>> >&nbsp=3D3B&nbsp=3D=
>3B&nbsp=3D3B info :=3D3D Unetdb.gethostbyname (ADR (host[0]))=3D3B<=3D> >BR=
>>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B IF info =3D3D NIL THEN IOError (Unexpected)=
>=3D3B EN=3D> >D=3D3B<BR>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B &lt=3D3B* ASSERT inf=
>o.h_length &lt=3D3B=3D3D BYT=3D> >ESIZE (Address) *&gt=3D3B<BR>> >&nbsp=3D3=
>B&nbsp=3D3B&nbsp=3D3B ua :=3D3D LOOPHOLE(info.h_addr_list=3D2C<BR>&nbsp=3D3=
>B&n=3D> >bsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D=
>3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D> >=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=
>=3D3B&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B UNTRACED REF UN=3D> >TRACED REF Uin.str=
>uct_in_addr)^^=3D3B<BR>&nbsp=3D3B&nbsp=3D3B&nbsp=3D3B RETURN LOOP=3D> >HOLE=
> (ua.s_addr=3D2C Address)=3D3B<BR>&nbsp=3D3B END GetHostAddr=3D3B<BR>> >&nb=
>sp=3D3B<BR>> >&nbsp=3D3B<BR>> >It is again disappointing to see such code d=
>uplication.<BR>> >&nbsp=3D3B<BR>> >&nbsp=3D3B<BR>> >I guess&nbsp=3D3BSameHo=
>st can duplicate the logic to predict the error state =3D> >and return fals=
>e&nbsp=3D3Bupon error?<BR>> >Duplicating the logic for a third time. :(<BR>=
>> >&nbsp=3D3B<BR>> ><BR>&nbsp=3D3B- Jay<BR><BR></body>> ></html>=3D> >> >--=
>_9e67232c-a064-417d-879e-227a77e310f9_--=
>
>--_b00371fe-730b-4981-9051-a874361296d7_
>Content-Type: text/html; charset="iso-8859-1"
>Content-Transfer-Encoding: quoted-printable
>
><html>
><head>
><style>
>.hmmessage P
>{
>margin:0px=3B
>padding:0px
>}
>body.hmmessage
>{
>font-size: 10pt=3B
>font-family:Verdana
>}
></style>
></head>
><body class=3D'hmmessage'>
>Do you know the right way?<BR>
>&nbsp=3B<BR>
>PPC_LINUX "just worked"=2C and I can check Solaris and Darwin.<BR>
>&nbsp=3B<BR>
>I don't want to edit /etc/hosts -- I use DHCP.<BR>
>Though DHCP has been bothering me -- only for some of my machines do names =
>resolve=2C so I end using IP addresses=2C which change sometimes=2C and I l=
>oop over them running ssh to all of them and "see what I get"=2C not ideal.=
><BR>
>&nbsp=3B<BR>
>&nbsp=3B- Jay<BR><BR><BR>&gt=3B To: jay.krell at cornell.edu<BR>&gt=3B Date: S=
>un=2C 11 Jan 2009 08:02:18 -0800<BR>&gt=3B From: mika at async.caltech.edu<BR>=
>&gt=3B CC: m3devel at elegosoft.com<BR>&gt=3B Subject: Re: [M3devel] Juno (X) =
>networking problem on AMD64_FREEBSD<BR>&gt=3B <BR>&gt=3B This is a screwy t=
>hing in Modula-3. A bug I would call it.<BR>&gt=3B <BR>&gt=3B I've noticed =
>a lot of networking M3 programs don't work right unless<BR>&gt=3B the retur=
>n value of Unix's "hostname" maps to a real IP address via<BR>&gt=3B gethos=
>tbyname. I accomplish it in practice by adding my hostname<BR>&gt=3B to /et=
>c/hosts.<BR>&gt=3B <BR>&gt=3B This is obviously not the right way to fix it=
>... <BR>&gt=3B <BR>&gt=3B Mika<BR>&gt=3B <BR>&gt=3B Jay writes:<BR>&gt=3B &=
>gt=3B--_9e67232c-a064-417d-879e-227a77e310f9_<BR>&gt=3B &gt=3BContent-Type:=
> text/plain=3B charset=3D"iso-8859-1"<BR>&gt=3B &gt=3BContent-Transfer-Enco=
>ding: quoted-printable<BR>&gt=3B &gt=3B<BR>&gt=3B &gt=3B<BR>&gt=3B &gt=3BHi=
>. Unix network programming question..<BR>&gt=3B &gt=3BAMD64_FREEBSD:<BR>&gt=
>=3B &gt=3B$DISPLAY is set to point back to Cygwin host.It works for PPC_LIN=
>UX.<BR>&gt=3B &gt=3B[jay at fbsdamd64a /cm3/bin]$ ./Juno<BR>&gt=3B &gt=3B*****=
>* runtime error:*** Exception "IPError.FatalError" not in RAISES li=3D<BR>&=
>gt=3B &gt=3Bst*** file "../src/common/IPError.m3"=3D2C line 27***<BR>&gt=3B=
> &gt=3BAbort trap: 6 (core dumped)[jay at fbsdamd64a /cm3/bin]$<BR>&gt=3B &gt=
>=3BIP.m3:<BR>&gt=3B &gt=3B=3D20<BR>&gt=3B &gt=3BPROCEDURE GetHostAddr(): Ad=
>dress =3D3D VAR hname: ARRAY [0..255] OF CHAR=3D3B =3D<BR>&gt=3B &gt=3B BEG=
>IN LOCK mu DO IF Unix.gethostname(ADR(hname[0])=3D2C BYTESIZE(hna=3D<BR>&gt=
>=3B &gt=3Bme)) # 0 THEN IPError.Die ()=3D3B END=3D3B VAR h :=3D3D Unetdb.g=
>=3D<BR>&gt=3B &gt=3Bethostbyname(ADR(hname[0]))=3D3B BEGIN IF h =3D3D NIL T=
>HEN IPError.Die()=3D<BR>&gt=3B &gt=3B=3D3B END=3D3B RETURN GetAddress(h)=3D=
>3B END=3D3B END=3D3B END GetHos=3D<BR>&gt=3B &gt=3BtAddr=3D3B<BR>&gt=3B &gt=
>=3BPROCEDURE GetAddress (ent: Unetdb.struct_hostent_star): Address =3D3D VA=
>R ua=3D<BR>&gt=3B &gt=3B: Uin.struct_in_addr=3D3B BEGIN &lt=3B* ASSERT ent.=
>h_length &lt=3B=3D3D BYTESIZE(Addr=3D<BR>&gt=3B &gt=3Bess) *&gt=3B ua :=3D3=
>D LOOPHOLE(ent.h_addr_list=3D2C UNTRACED =3D<BR>&gt=3B &gt=3BREF UNTRACED R=
>EF Uin.struct_in_addr)^^=3D3B RETURN LOOPHOLE(ua.s_addr=3D2C A=3D<BR>&gt=3B=
> &gt=3Bddress)=3D3B END GetAddress=3D3B<BR>&gt=3B &gt=3B=3D20<BR>&gt=3B &gt=
>=3Bgethostbyname is failing.<BR>&gt=3B &gt=3B=3D20<BR>&gt=3B &gt=3BAnalogou=
>s C code also fails:<BR>&gt=3B &gt=3B=3D20<BR>&gt=3B &gt=3B[jay at fbsdamd64a =
>/cm3/bin]$ cat ~/5.c#include &lt=3Bassert.h&gt=3B#include &lt=3Bnetdb.h&gt=
>=3B#i=3D<BR>&gt=3B &gt=3Bnclude &lt=3Bstdio.h&gt=3B#include &lt=3Berrno.h&g=
>t=3Btypedef struct hostent hostent_t=3D3B<BR>&gt=3B &gt=3B=3D20<BR>&gt=3B &=
>gt=3Bint main(){ char hostname[200]=3D3B hostent_t* h=3D3B int i=3D3B<BR>&g=
>t=3B &gt=3B i =3D3D gethostname(hostname=3D2C 200)=3D3B assert(i =3D3D=3D3D=
> 0)=3D3B printf("hostna=3D<BR>&gt=3B &gt=3Bme: %s\n"=3D2C hostname)=3D3B h =
>=3D3D gethostbyname(hostname)=3D3B herror("foo")=3D3B=3D<BR>&gt=3B &gt=3B p=
>rintf("%p %d %d\n"=3D2C h=3D2C errno=3D2C h_errno)=3D3B assert(h)=3D3B retu=
>rn 0=3D3B}<BR>&gt=3B &gt=3B=3D20<BR>&gt=3B &gt=3Bherror says "unknown host"=
>.<BR>&gt=3B &gt=3BStack is:<BR>&gt=3B &gt=3B at ../src/runtime/ex_frame/RTE=
>xFrame.m3:58#13 0x0000000801a7f2b3 in RTH=3D<BR>&gt=3B &gt=3Books__Raise (M=
>3_AJWxb1_ex=3D3DError accessing memory address 0x8000ffffd278: =3D<BR>&gt=
>=3B &gt=3BBad address.) at ../src/runtime/common/RTHooks.m3:79#14 0x0000000=
>80169c8=3D<BR>&gt=3B &gt=3Bd3 in IPError__Die () at ../src/common/IPError.m=
>3:27#15 0x0000000801698a3e =3D<BR>&gt=3B &gt=3Bin IP__GetHostAddr (M3_BCxjP=
>n__result=3D3DError accessing memory address 0x80=3D<BR>&gt=3B &gt=3B00ffff=
>d338: Bad address.) at ../src/POSIX/IP.m3:82#16 0x00000008012133d0=3D<BR>&g=
>t=3B &gt=3B in XSharedMem__SameHost (M3_AQuuui_trsl=3D3DError accessing mem=
>ory address 0=3D<BR>&gt=3B &gt=3Bx8000ffffd4d8: Bad address.) at ../src/xvb=
>t/XSharedMem.m3:96#17 0x000000=3D<BR>&gt=3B &gt=3B0801212ab7 in XSharedMem_=
>_InitXClient (M3_AQuuui_v=3D3DError accessing memory=3D<BR>&gt=3B &gt=3B ad=
>dress 0x8000ffffd648: Bad address.) at ../src/xvbt/XSharedMem.m3:29#1=3D<BR=
>>&gt=3B &gt=3B8 0x0000000801211819 in XExtensions__InitXClient (M3_AQuuui_x=
>client=3D3DError=3D<BR>&gt=3B &gt=3B accessing memory address 0x8000ffffd7f=
>8: Bad address.) at ../src/xvbt/X=3D<BR>&gt=3B &gt=3BExtensions.m3:14#19 0x=
>00000008012467a4 in XClientF__Connect (M3_Bd56fi_inst=3D<BR>&gt=3B &gt=3B=
>=3D3D0x1879b=3D2C M3_AQuuui_trsl=3D3D0x6) at ../src/xvbt/XClientF.m3:583---=
>Typ=3D<BR>&gt=3B &gt=3Be &lt=3Breturn&gt=3B to continue=3D2C or q &lt=3Bret=
>urn&gt=3B to quit---(More stack frames follow=3D<BR>&gt=3B &gt=3B...)(gdb)<=
>BR>&gt=3B &gt=3B(* return TRUE if server and client are on same host *)PROC=
>EDURE SameHost (=3D<BR>&gt=3B &gt=3Btrsl: XClient.T): BOOLEAN =3D3D VAR dis=
>play :=3D3D DisplayH=3D<BR>&gt=3B &gt=3Bost(trsl)=3D3B displayAddr: IP.Addr=
>ess=3D3B BEGIN IF display =3D3D NIL THE=3D<BR>&gt=3B &gt=3BN RETURN TRUE=3D=
>3B END=3D3B<BR>&gt=3B &gt=3B TRY IF NOT IP.GetHostByName(display=3D2C displ=
>ayAddr) THEN RETURN FA=3D<BR>&gt=3B &gt=3BLSE=3D3B END=3D3B RETURN displayA=
>ddr =3D3D IP.GetHostAddr()=3D3B EXCEPT =3D<BR>&gt=3B &gt=3B| IP.Error =3D3D=
>&gt=3B RETURN FALSE=3D3B END=3D3B END SameHost=3D3B<BR>&gt=3B &gt=3B=3D20<B=
>R>&gt=3B &gt=3BThoughts?<BR>&gt=3B &gt=3B=3D20<BR>&gt=3B &gt=3BPerhaps my n=
>etwork isn't setup well=3D2C like I should add the local machine =3D<BR>&gt=
>=3B &gt=3Bto /etc/hosts.I think this can be made to fail gracefully though.=
>It seems l=3D<BR>&gt=3B &gt=3Bike it has nothing to do with AMD64_FREEBSD=
>=3D2C but could have to do with Fr=3D<BR>&gt=3B &gt=3BeeBSD.<BR>&gt=3B &gt=
>=3B=3D20<BR>&gt=3B &gt=3BSeems like SocketPosix has nearly the exact same c=
>ode but appearsmore forgi=3D<BR>&gt=3B &gt=3Bving.. IOError instead of Fata=
>l?<BR>&gt=3B &gt=3B=3D20<BR>&gt=3B &gt=3BSocketPosix.m3:<BR>&gt=3B &gt=3B=
>=3D20<BR>&gt=3B &gt=3BPROCEDURE GetHostAddr (): Address RAISES {OSError.E} =
>=3D3D VAR host : AR=3D<BR>&gt=3B &gt=3BRAY [0..255] OF CHAR=3D3B info : Une=
>tdb.struct_hostent_star=3D3B ua : U=3D<BR>&gt=3B &gt=3Bin.struct_in_addr=3D=
>3B BEGIN IF Unix.gethostname (ADR (host[0])=3D2C BYTESI=3D<BR>&gt=3B &gt=3B=
>ZE (host)) # 0 THEN IOError (Unexpected)=3D3B END=3D3B<BR>&gt=3B &gt=3B inf=
>o :=3D3D Unetdb.gethostbyname (ADR (host[0]))=3D3B IF info =3D3D NIL TH=3D<=
>BR>&gt=3B &gt=3BEN IOError (Unexpected)=3D3B END=3D3B &lt=3B* ASSERT info.h=
>_length &lt=3B=3D3D BYTESIZE =3D<BR>&gt=3B &gt=3B(Address) *&gt=3B<BR>&gt=
>=3B &gt=3B ua :=3D3D LOOPHOLE(info.h_addr_list=3D2C UNTRACED REF UNT=3D<BR>=
>&gt=3B &gt=3BRACED REF Uin.struct_in_addr)^^=3D3B RETURN LOOPHOLE (ua.s_add=
>r=3D2C Address=3D<BR>&gt=3B &gt=3B)=3D3B END GetHostAddr=3D3B<BR>&gt=3B &gt=
>=3B=3D20<BR>&gt=3B &gt=3B=3D20<BR>&gt=3B &gt=3BIt is again disappointing to=
> see such code duplication.<BR>&gt=3B &gt=3B=3D20<BR>&gt=3B &gt=3B=3D20<BR>=
>&gt=3B &gt=3BI guess SameHost can duplicate the logic to predict the error =
>state and ret=3D<BR>&gt=3B &gt=3Burn false upon error?<BR>&gt=3B &gt=3BDupl=
>icating the logic for a third time. :(<BR>&gt=3B &gt=3B=3D20<BR>&gt=3B &gt=
>=3B - Jay=3D<BR>&gt=3B &gt=3B<BR>&gt=3B &gt=3B--_9e67232c-a064-417d-879e-22=
>7a77e310f9_<BR>&gt=3B &gt=3BContent-Type: text/html=3B charset=3D"iso-8859-=
>1"<BR>&gt=3B &gt=3BContent-Transfer-Encoding: quoted-printable<BR>&gt=3B &g=
>t=3B<BR>&gt=3B &gt=3B&lt=3Bhtml&gt=3B<BR>&gt=3B &gt=3B&lt=3Bhead&gt=3B<BR>&=
>gt=3B &gt=3B&lt=3Bstyle&gt=3B<BR>&gt=3B &gt=3B.hmmessage P<BR>&gt=3B &gt=3B=
>{<BR>&gt=3B &gt=3Bmargin:0px=3D3B<BR>&gt=3B &gt=3Bpadding:0px<BR>&gt=3B &gt=
>=3B}<BR>&gt=3B &gt=3Bbody.hmmessage<BR>&gt=3B &gt=3B{<BR>&gt=3B &gt=3Bfont-=
>size: 10pt=3D3B<BR>&gt=3B &gt=3Bfont-family:Verdana<BR>&gt=3B &gt=3B}<BR>&g=
>t=3B &gt=3B&lt=3B/style&gt=3B<BR>&gt=3B &gt=3B&lt=3B/head&gt=3B<BR>&gt=3B &=
>gt=3B&lt=3Bbody class=3D3D'hmmessage'&gt=3B<BR>&gt=3B &gt=3BHi. Unix networ=
>k programming question..&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&lt=3BBR&gt=3BAMD64_=
>FREEBSD:&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&lt=3BBR&gt=3B$DISPLAY is set to poi=
>nt back to Cygwin host.&lt=3BBR&gt=3BIt works for PPC_LINUX=3D<BR>&gt=3B &g=
>t=3B.&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&lt=3BBR&gt=3B[jay at fbsdamd64a /cm3/bin]=
>$ ./Juno&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&lt=3BBR&gt=3B***&lt=3BBR&gt=3B*** r=
>untime error:&lt=3BBR&gt=3B***&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=
>=3D3B Exception "IPE=3D<BR>&gt=3B &gt=3Brror.FatalError" not in RAISES list=
>&lt=3BBR&gt=3B***&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B file "..=
>=3D<BR>&gt=3B &gt=3B/src/common/IPError.m3"=3D2C line 27&lt=3BBR&gt=3B***&l=
>t=3BBR&gt=3B<BR>&gt=3B &gt=3B&lt=3BBR&gt=3BAbort trap: 6 (core dumped)&lt=
>=3BBR&gt=3B[jay at fbsdamd64a /cm3/bin]$&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&lt=3BB=
>R&gt=3BIP.m3:&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&amp=3Bnbsp=3D3B&lt=3BBR&gt=3B<=
>BR>&gt=3B &gt=3BPROCEDURE GetHostAddr(): Address =3D3D&lt=3BBR&gt=3B&amp=3B=
>nbsp=3D3B VAR hname: ARRAY [0..255] =3D<BR>&gt=3B OF CHAR=3D3B&lt=3BBR&gt=
>=3B&amp=3Bnbsp=3D3B BEGIN&lt=3BBR&gt=3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=
>=3Bnbsp=3D3B LOCK mu DO&lt=3BBR&gt=3B&amp=3Bnbs=3D<BR>&gt=3B &gt=3Bp=3D3B&a=
>mp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B IF Unix.geth=
>ostname(ADR(hname[0])=3D2C B=3D<BR>&gt=3B &gt=3BYTESIZE(hname)) # 0 THEN&lt=
>=3BBR&gt=3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B=
>&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D<BR>&gt=3B &gt=3B=3D3B&amp=3Bnbsp=3D3B IPErro=
>r.Die ()=3D3B&lt=3BBR&gt=3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B=
>&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B E=3D<BR>&gt=3B &gt=3BND=3D3B&lt=3BBR&gt=3B=
>&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=
>=3D3B VAR h :=3D3D Unetdb.gethost=3D<BR>&gt=3B &gt=3Bbyname(ADR(hname[0]))=
>=3D3B BEGIN&lt=3BBR&gt=3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&a=
>mp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3B=3D<BR>&gt=3B &gt=3Bnbsp=3D3B&amp=3Bnb=
>sp=3D3B IF h =3D3D NIL THEN IPError.Die()=3D3B END=3D3B&lt=3BBR&gt=3B&amp=
>=3Bnbsp=3D3B&amp=3Bnbsp=3D<BR>&gt=3B &gt=3B=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=
>=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B RETURN GetAddress(h)=
>=3D3B&lt=3BBR&gt=3B&amp=3Bnbs=3D<BR>&gt=3B &gt=3Bp=3D3B&amp=3Bnbsp=3D3B&amp=
>=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B END=3D3B&lt=3BBR&gt=3B&amp=3Bn=
>bsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B END=3D<BR>&gt=3B &gt=3B=3D3B&lt=3B=
>BR&gt=3B&amp=3Bnbsp=3D3B END GetHostAddr=3D3B&lt=3BBR&gt=3B<BR>&gt=3B &gt=
>=3B&lt=3BBR&gt=3BPROCEDURE GetAddress (ent: Unetdb.struct_hostent_star): Ad=
>dress =3D3D&lt=3BBR&gt=3B=3D<BR>&gt=3B &gt=3B&amp=3Bnbsp=3D3B VAR ua: Uin.s=
>truct_in_addr=3D3B&lt=3BBR&gt=3B&amp=3Bnbsp=3D3B BEGIN&lt=3BBR&gt=3B&amp=3B=
>nbsp=3D3B&amp=3Bnbsp=3D<BR>&gt=3B &gt=3B=3D3B&amp=3Bnbsp=3D3B &amp=3Blt=3D3=
>B* ASSERT ent.h_length &amp=3Blt=3D3B=3D3D BYTESIZE(Address) *&amp=3Bgt=3D3=
>B=3D<BR>&gt=3B &gt=3B&lt=3BBR&gt=3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bn=
>bsp=3D3B ua :=3D3D LOOPHOLE(ent.h_addr_list=3D2C&lt=3BBR&gt=3B&amp=3Bnbsp=
>=3D<BR>&gt=3B &gt=3B=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&a=
>mp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=
>=3D3B&amp=3Bnbsp=3D3B=3D<BR>&gt=3B &gt=3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&a=
>mp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=
>=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B UN=3D<BR>&gt=3B &gt=3BTRACED REF UNTR=
ACED REF Uin.struct_in_addr)^^=3D3B&lt=3BBR&gt=3B&amp=3Bnbsp=3D3B&amp=3Bnbs=
>p=3D3B&amp=3Bnbsp=3D<BR>&gt=3B &gt=3B=3D3B RETURN LOOPHOLE(ua.s_addr=3D2C A=
>ddress)=3D3B&lt=3BBR&gt=3B&amp=3Bnbsp=3D3B END GetAddress=3D3B&lt=3B=3D<BR>=
>&gt=3B &gt=3BBR&gt=3B<BR>&gt=3B &gt=3B&amp=3Bnbsp=3D3B&lt=3BBR&gt=3B<BR>&gt=
>=3B &gt=3Bgethostbyname is failing.&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&lt=3BBR&=
>gt=3B&amp=3Bnbsp=3D3B&lt=3BBR&gt=3B<BR>&gt=3B &gt=3BAnalogous C code also f=
>ails:&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&amp=3Bnbsp=3D3B&lt=3BBR&gt=3B<BR>&gt=
>=3B &gt=3B&lt=3BBR&gt=3B[jay at fbsdamd64a /cm3/bin]$ cat ~/5.c&lt=3BBR&gt=3B#=
>include &amp=3Blt=3D3Bassert.h&amp=3Bgt=3D3B&lt=3BB=3D<BR>&gt=3B &gt=3BR&gt=
>=3B#include &amp=3Blt=3D3Bnetdb.h&amp=3Bgt=3D3B&lt=3BBR&gt=3B#include &amp=
>=3Blt=3D3Bstdio.h&amp=3Bgt=3D3B&lt=3BBR&gt=3B#include =3D<BR>&gt=3B &gt=3B&=
>amp=3Blt=3D3Berrno.h&amp=3Bgt=3D3B&lt=3BBR&gt=3Btypedef struct hostent host=
>ent_t=3D3B&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&amp=3Bnbsp=3D3B&lt=3BBR&gt=3B<BR>=
>&gt=3B &gt=3Bint main()&lt=3BBR&gt=3B{&lt=3BBR&gt=3B&amp=3Bnbsp=3D3Bchar ho=
>stname[200]=3D3B&lt=3BBR&gt=3B&amp=3Bnbsp=3D3Bhostent_t* h=3D3B=3D<BR>&gt=
>=3B &gt=3B&lt=3BBR&gt=3B&amp=3Bnbsp=3D3Bint i=3D3B&lt=3BBR&gt=3B<BR>&gt=3B =
>&gt=3B&amp=3Bnbsp=3D3Bi =3D3D gethostname(hostname=3D2C 200)=3D3B&lt=3BBR&g=
>t=3B&amp=3Bnbsp=3D3Bassert(i =3D3D=3D3D 0)=3D<BR>&gt=3B &gt=3B=3D3B&lt=3BBR=
>&gt=3B&amp=3Bnbsp=3D3Bprintf("hostname: %s\n"=3D2C hostname)=3D3B&lt=3BBR&g=
>t=3B&amp=3Bnbsp=3D3Bh =3D3D get=3D<BR>&gt=3B &gt=3Bhostbyname(hostname)=3D3=
>B&lt=3BBR&gt=3B&amp=3Bnbsp=3D3Bherror("foo")=3D3B&lt=3BBR&gt=3B&amp=3Bnbsp=
>=3D3Bprintf("%p %=3D<BR>&gt=3B &gt=3Bd %d\n"=3D2C h=3D2C errno=3D2C h_errno=
>)=3D3B&lt=3BBR&gt=3B&amp=3Bnbsp=3D3Bassert(h)=3D3B&lt=3BBR&gt=3B&amp=3Bnbsp=
>=3D3Bret=3D<BR>&gt=3B &gt=3Burn 0=3D3B&lt=3BBR&gt=3B}&lt=3BBR&gt=3B<BR>&gt=
>=3B &gt=3B&amp=3Bnbsp=3D3B&lt=3BBR&gt=3B<BR>&gt=3B &gt=3Bherror says "unkno=
>wn host".&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&lt=3BBR&gt=3BStack is:&lt=3BBR&gt=
>=3B<BR>&gt=3B &gt=3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B at ../=
>src/runtime/ex_frame/RTExFrame.m3:58&lt=3BBR&gt=3B#13 =3D<BR>&gt=3B &gt=3B0=
>x0000000801a7f2b3 in RTHooks__Raise (M3_AJWxb1_ex=3D3DError accessing memor=
>y=3D<BR>&gt=3B &gt=3B ad&lt=3BBR&gt=3Bdress 0x8000ffffd278: Bad address.&lt=
>=3BBR&gt=3B)&lt=3BBR&gt=3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B =
>=3D<BR>&gt=3B &gt=3Bat ../src/runtime/common/RTHooks.m3:79&lt=3BBR&gt=3B#14=
> 0x000000080169c8d3 in IPError=3D<BR>&gt=3B &gt=3B__Die () at ../src/common=
>/IPError.m3:27&lt=3BBR&gt=3B#15 0x0000000801698a3e in IP__Ge=3D<BR>&gt=3B &=
>gt=3BtHostAddr (M3_BCxjPn__result=3D3DError accessing mem&lt=3BBR&gt=3Bory =
>address 0x8000fff=3D<BR>&gt=3B &gt=3Bfd338: Bad address.&lt=3BBR&gt=3B)&lt=
>=3BBR&gt=3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B at ../src/POSIX=
>/IP.m3:=3D<BR>&gt=3B &gt=3B82&lt=3BBR&gt=3B#16 0x00000008012133d0 in XShare=
>dMem__SameHost (M3_AQuuui_trsl=3D3DErro=3D<BR>&gt=3B &gt=3Br accessing m&lt=
>=3BBR&gt=3Bemory address 0x8000ffffd4d8: Bad address.&lt=3BBR&gt=3B)&lt=3BB=
>R&gt=3B&amp=3Bnbsp=3D<BR>&gt=3B &gt=3B=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B=
> at ../src/xvbt/XSharedMem.m3:96&lt=3BBR&gt=3B#17 0x0000000801212a=3D<BR>&g=
>t=3B &gt=3Bb7 in XSharedMem__InitXClient (M3_AQuuui_v=3D3DError accessing m=
>&lt=3BBR&gt=3Bemory add=3D<BR>&gt=3B &gt=3Bress 0x8000ffffd648: Bad address=
>.&lt=3BBR&gt=3B)&lt=3BBR&gt=3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=
>=3D3B at ../sr=3D<BR>&gt=3B &gt=3Bc/xvbt/XSharedMem.m3:29&lt=3BBR&gt=3B#18 =
>0x0000000801211819 in XExtensions__InitXClie=3D<BR>&gt=3B &gt=3Bnt (M3_AQuu=
>ui_xclient=3D3DError acce&lt=3BBR&gt=3Bssing memory address 0x8000ffffd7f8:=
> =3D<BR>&gt=3B &gt=3BBad address.&lt=3BBR&gt=3B)&lt=3BBR&gt=3B&amp=3Bnbsp=
>=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B at ../src/xvbt/XExtensions.m3=3D<BR>&=
>gt=3B &gt=3B:14&lt=3BBR&gt=3B#19 0x00000008012467a4 in XClientF__Connect (M=
>3_Bd56fi_inst=3D3D0x1879=3D<BR>&gt=3B &gt=3Bb=3D2C&lt=3BBR&gt=3B&amp=3Bnbsp=
>=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B M3_AQuuui_trsl=3D3D0x6) at ../src/xvb=
>t/XClie=3D<BR>&gt=3B &gt=3BntF.m3:583&lt=3BBR&gt=3B---Type &amp=3Blt=3D3Bre=
>turn&amp=3Bgt=3D3B to continue=3D2C or q &amp=3Blt=3D3Breturn&amp=3Bg=3D<BR=
>>&gt=3B &gt=3Bt=3D3B to quit---&lt=3BBR&gt=3B(More stack frames follow...)&=
>lt=3BBR&gt=3B(gdb)&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&lt=3BBR&gt=3B(* return TR=
>UE if server and client are on same host *)&lt=3BBR&gt=3BPROCEDURE Sa=3D<BR=
>>&gt=3B &gt=3BmeHost (trsl: XClient.T): BOOLEAN =3D3D&lt=3BBR&gt=3B&amp=3Bn=
>bsp=3D3B VAR&lt=3BBR&gt=3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bn=3D<BR>&g=
>t=3B &gt=3Bbsp=3D3B display&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B=
>&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=
>=3D<BR>&gt=3B &gt=3B=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&a=
>mp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=
>=3D3B :=3D3D Di=3D<BR>&gt=3B &gt=3BsplayHost(trsl)=3D3B&lt=3BBR&gt=3B&amp=
>=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B displayAddr: IP.Address=3D3B&l=
>t=3BB=3D<BR>&gt=3B &gt=3BR&gt=3B&amp=3Bnbsp=3D3B BEGIN&lt=3BBR&gt=3B&amp=3B=
>nbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B IF display =3D3D NIL THEN RETURN=
>=3D<BR>&gt=3B &gt=3B TRUE=3D3B END=3D3B&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&amp=
>=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B TRY&lt=3BBR&gt=3B&amp=3Bnbsp=
>=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B IF=3D=
><BR>&gt=3B &gt=3B NOT IP.GetHostByName(display=3D2C displayAddr) THEN RETUR=
>N FALSE=3D3B END=3D3B&lt=3BB=3D<BR>&gt=3B &gt=3BR&gt=3B&amp=3Bnbsp=3D3B&amp=
>=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B RETURN display=
>Addr =3D3D IP.GetHos=3D<BR>&gt=3B &gt=3BtAddr()=3D3B&lt=3BBR&gt=3B&amp=3Bnb=
>sp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B EXCEPT&lt=3BBR&gt=3B&amp=3Bnbsp=3D3=
>B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B |=3D<BR>&gt=3B &gt=3B IP.Error =3D3D&amp=
>=3Bgt=3D3B RETURN FALSE=3D3B&lt=3BBR&gt=3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&=
>amp=3Bnbsp=3D3B END=3D3B&lt=3BBR&gt=3B&amp=3B=3D<BR>&gt=3B &gt=3Bnbsp=3D3B =
>END SameHost=3D3B&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&amp=3Bnbsp=3D3B&lt=3BBR&gt=
>=3B<BR>&gt=3B &gt=3BThoughts?&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&amp=3Bnbsp=3D3=
>B&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&lt=3BBR&gt=3BPerhaps my network isn't setu=
>p well=3D2C like I should add the local mach=3D<BR>&gt=3B &gt=3Bine to /etc=
>/hosts.&lt=3BBR&gt=3BI think this can be made to fail gracefully though.&lt=
>=3BB=3D<BR>&gt=3B &gt=3BR&gt=3BIt seems like it has nothing to do with AMD6=
>4_FREEBSD=3D2C but could have t=3D<BR>&gt=3B &gt=3Bo do with FreeBSD.&lt=3B=
>BR&gt=3B<BR>&gt=3B &gt=3B&lt=3BBR&gt=3B&amp=3Bnbsp=3D3B&lt=3BBR&gt=3B<BR>&g=
>t=3B &gt=3BSeems like SocketPosix has nearly the exact same code but appear=
>s&lt=3BBR&gt=3Bmore f=3D<BR>&gt=3B &gt=3Borgiving.. IOError instead of Fata=
>l?&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&amp=3Bnbsp=3D3B&lt=3BBR&gt=3B<BR>&gt=3B &=
>gt=3B&lt=3BBR&gt=3BSocketPosix.m3:&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&amp=3Bnbs=
>p=3D3B&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&lt=3BBR&gt=3BPROCEDURE GetHostAddr ()=
>: Address&lt=3BBR&gt=3B&amp=3Bnbsp=3D3B RAISES {OSError.E} =3D3D&lt=3BBR=3D=
><BR>&gt=3B &gt=3B&gt=3B&amp=3Bnbsp=3D3B VAR&lt=3BBR&gt=3B&amp=3Bnbsp=3D3B&a=
>mp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B host : ARRAY [0..255] OF CHAR=3D3B&lt=3B=3D<=
>BR>&gt=3B &gt=3BBR&gt=3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B in=
>fo : Unetdb.struct_hostent_star=3D3B&lt=3BBR&gt=3B&amp=3Bnbsp=3D<BR>&gt=3B =
>&gt=3B=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B ua&amp=3Bnbsp=3D3B&amp=3Bnbsp=
>=3D3B : Uin.struct_in_addr=3D3B&lt=3BBR&gt=3B&amp=3Bnbsp=3D3B =3D<BR>&gt=3B=
> &gt=3BBEGIN&lt=3BBR&gt=3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B =
>IF Unix.gethostname (ADR (host[0])=3D2C BYT=3D<BR>&gt=3B &gt=3BESIZE (host)=
>) # 0 THEN&lt=3BBR&gt=3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&am=
>p=3Bnbsp=3D3B&amp=3Bnbsp=3D3B IOError =3D<BR>&gt=3B &gt=3B(Unexpected)=3D3B=
>&lt=3BBR&gt=3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B END=3D3B&lt=
>=3BBR&gt=3B<BR>&gt=3B &gt=3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3=
>B info :=3D3D Unetdb.gethostbyname (ADR (host[0]))=3D3B&lt=3B=3D<BR>&gt=3B =
>&gt=3BBR&gt=3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B IF info =3D3=
>D NIL THEN IOError (Unexpected)=3D3B EN=3D<BR>&gt=3B &gt=3BD=3D3B&lt=3BBR&g=
>t=3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B &amp=3Blt=3D3B* ASSERT=
> info.h_length &amp=3Blt=3D3B=3D3D BYT=3D<BR>&gt=3B &gt=3BESIZE (Address) *=
>&amp=3Bgt=3D3B&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D=
>3B&amp=3Bnbsp=3D3B ua :=3D3D LOOPHOLE(info.h_addr_list=3D2C&lt=3BBR&gt=3B&a=
>mp=3Bnbsp=3D3B&amp=3Bn=3D<BR>&gt=3B &gt=3Bbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnb=
>sp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=
>=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D<BR>&gt=3B &gt=3B=3D3B&amp=3Bnbsp=
>=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&amp=
>=3Bnbsp=3D3B&amp=3Bnbsp=3D3B UNTRACED REF UN=3D<BR>&gt=3B &gt=3BTRACED REF =
>Uin.struct_in_addr)^^=3D3B&lt=3BBR&gt=3B&amp=3Bnbsp=3D3B&amp=3Bnbsp=3D3B&am=
>p=3Bnbsp=3D3B RETURN LOOP=3D<BR>&gt=3B &gt=3BHOLE (ua.s_addr=3D2C Address)=
>=3D3B&lt=3BBR&gt=3B&amp=3Bnbsp=3D3B END GetHostAddr=3D3B&lt=3BBR&gt=3B<BR>&=
>gt=3B &gt=3B&amp=3Bnbsp=3D3B&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&amp=3Bnbsp=3D3B=
>&lt=3BBR&gt=3B<BR>&gt=3B &gt=3BIt is again disappointing to see such code d=
>uplication.&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&amp=3Bnbsp=3D3B&lt=3BBR&gt=3B<BR=
>>&gt=3B &gt=3B&amp=3Bnbsp=3D3B&lt=3BBR&gt=3B<BR>&gt=3B &gt=3BI guess&amp=3B=
>nbsp=3D3BSameHost can duplicate the logic to predict the error state =3D<BR=
>>&gt=3B &gt=3Band return false&amp=3Bnbsp=3D3Bupon error?&lt=3BBR&gt=3B<BR>=
>&gt=3B &gt=3BDuplicating the logic for a third time. :(&lt=3BBR&gt=3B<BR>&g=
>t=3B &gt=3B&amp=3Bnbsp=3D3B&lt=3BBR&gt=3B<BR>&gt=3B &gt=3B&lt=3BBR&gt=3B&am=
>p=3Bnbsp=3D3B- Jay&lt=3BBR&gt=3B&lt=3BBR&gt=3B&lt=3B/body&gt=3B<BR>&gt=3B &=
>gt=3B&lt=3B/html&gt=3B=3D<BR>&gt=3B &gt=3B<BR>&gt=3B &gt=3B--_9e67232c-a064=
>-417d-879e-227a77e310f9_--<BR><BR></body>
></html>=
>
>--_b00371fe-730b-4981-9051-a874361296d7_--



More information about the M3devel mailing list