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