[M3devel] Juno (X) networking problem on AMD64_FREEBSD
Jay
jay.krell at cornell.edu
Mon Jan 12 10:12:44 CET 2009
PPC_LINUX not PPC_DARWIN.
I think.
And at one point AMD64_LINUX (same machine as AMD64_FREEBSD, multiboot).I think I tested I386_OPENBSD Juno too and it worked,I don't remember. Oh, but that was in a VM, so different networking setup.
This is Trestle startup, seeing if there mightbe shared memory available between the X client and server.
If $DISPLAY is set, to specify the server, it wants to comparethat against "current", the client.You know, if I set DISPLAY=:0.0 or localhost:0.0, don't penalize perf,but if it really is remote, then do penalize perf.
/Something/ like that.
I hardly read the code..
- Jay> To: jay.krell at cornell.edu> Date: Mon, 12 Jan 2009 01:06:30 -0800> From: mika at async.caltech.edu> CC: m3devel at elegosoft.com> Subject: Re: [M3devel] Juno (X) networking problem on AMD64_FREEBSD> > 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>*** =3D3B =3D3B =3D3B Exception "IPE=> >=3D> >rror.FatalError" not in RAISES list<BR>*** =3D3B =3D3B => >=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>> > =3D3B<BR>> >PROCEDURE GetHostAddr(): Address =3D3D<BR> =3D3B => >VAR hname: ARRAY [0..255] =3D> OF CHAR=3D3B<BR> =3D3B BEGIN<BR> =3D=> >3B =3D3B =3D3B LOCK mu DO<BR>&nbs=3D> >p=3D3B =3D3B =3D3B&n=> >bsp=3D3B =3D3B IF Unix.gethostname(ADR(hname[0])=3D2C B=3D> >YTESIZE(hn=> >ame)) # 0 THEN<BR> =3D3B =3D3B =3D3B =3D3B =3D3B => >=3D> >=3D3B =3D3B IPError.Die ()=3D3B<BR> =3D3B =3D3B =3D3B=> > =3D3B =3D3B E=3D> >ND=3D3B<BR> =3D3B =3D3B =3D3B => >=3D3B =3D3B VAR h :=3D3D Unetdb.gethost=3D> >byname(ADR(hname[0]))=3D3B=> > BEGIN<BR> =3D3B =3D3B =3D3B =3D3B =3D3B&=3D> >nbsp=3D3=> >B =3D3B IF h =3D3D NIL THEN IPError.Die()=3D3B END=3D3B<BR> =3D3B&n=> >bsp=3D> >=3D3B =3D3B =3D3B =3D3B =3D3B =3D3B RETURN Get=> >Address(h)=3D3B<BR>&nbs=3D> >p=3D3B =3D3B =3D3B =3D3B =3D3B=> > END=3D3B<BR> =3D3B =3D3B =3D3B END=3D> >=3D3B<BR> =3D3B EN=> >D GetHostAddr=3D3B<BR>> ><BR>PROCEDURE GetAddress (ent: Unetdb.struct_hoste=> >nt_star): Address =3D3D<BR>=3D> > =3D3B VAR ua: Uin.struct_in_addr=3D3B=> ><BR> =3D3B BEGIN<BR> =3D3B =3D> >=3D3B =3D3B <=3D3B* ASSE=> >RT ent.h_length <=3D3B=3D3D BYTESIZE(Address) *>=3D3B=3D> ><BR> =3D=> >3B =3D3B =3D3B ua :=3D3D LOOPHOLE(ent.h_addr_list=3D2C<BR> =3D>=> > >=3D3B =3D3B =3D3B =3D3B =3D3B =3D3B =3D3B =3D=> >3B =3D3B =3D3B=3D> > =3D3B =3D3B =3D3B =3D3B => >=3D3B =3D3B =3D3B =3D3B =3D3B UN=3D> >TRACED REF UNTRACED R=> >EF Uin.struct_in_addr)^^=3D3B<BR> =3D3B =3D3B =3D> >=3D3B RETUR=> >N LOOPHOLE(ua.s_addr=3D2C Address)=3D3B<BR> =3D3B END GetAddress=3D3B<=> >=3D> >BR>> > =3D3B<BR>> >gethostbyname is failing.<BR>> ><BR> =3D3B=> ><BR>> >Analogous C code also fails:<BR>> > =3D3B<BR>> ><BR>[jay at fbsdamd=> >64a /cm3/bin]$ cat ~/5.c<BR>#include <=3D3Bassert.h>=3D3B<B=3D> >R>#inc=> >lude <=3D3Bnetdb.h>=3D3B<BR>#include <=3D3Bstdio.h>=3D3B<BR>#includ=> >e =3D> ><=3D3Berrno.h>=3D3B<BR>typedef struct hostent hostent_t=3D3B<BR=> >>> > =3D3B<BR>> >int main()<BR>{<BR> =3D3Bchar hostname[200]=3D3B<B=> >R> =3D3Bhostent_t* h=3D3B=3D> ><BR> =3D3Bint i=3D3B<BR>> > =3D3=> >Bi =3D3D gethostname(hostname=3D2C 200)=3D3B<BR> =3D3Bassert(i =3D3D=3D=> >3D 0)=3D> >=3D3B<BR> =3D3Bprintf("hostname: %s\n"=3D2C hostname)=3D3B<B=> >R> =3D3Bh =3D3D get=3D> >hostbyname(hostname)=3D3B<BR> =3D3Bherror(=> >"foo")=3D3B<BR> =3D3Bprintf("%p %=3D> >d %d\n"=3D2C h=3D2C errno=3D2C h=> >_errno)=3D3B<BR> =3D3Bassert(h)=3D3B<BR> =3D3Bret=3D> >urn 0=3D3B<B=> >R>}<BR>> > =3D3B<BR>> >herror says "unknown host".<BR>> ><BR>Stack is:<=> >BR>> > =3D3B =3D3B =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=> >> =3D3B =3D3B =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> =3D3B =3D3B =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 =3D3B =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> => >=3D3B =3D3B =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>=> > =3D3B =3D3B =3D3B at ../src/xvbt/XExtensions.m3=3D> >:14<BR>#1=> >9 0x00000008012467a4 in XClientF__Connect (M3_Bd56fi_inst=3D3D0x1879=3D> >b=> >=3D2C<BR> =3D3B =3D3B =3D3B M3_AQuuui_trsl=3D3D0x6) at ../src/x=> >vbt/XClie=3D> >ntF.m3:583<BR>---Type <=3D3Breturn>=3D3B to continue=3D2=> >C or q <=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> => >=3D3B VAR<BR> =3D3B =3D3B&n=3D> >bsp=3D3B display =3D3B =3D=> >3B =3D3B =3D3B =3D3B =3D3B =3D3B =3D> >=3D3B => >=3D3B =3D3B =3D3B =3D3B =3D3B =3D3B =3D3B =3D3B=> :=3D3D Di=3D> >splayHost(trsl)=3D3B<BR> =3D3B =3D3B =3D3B disp=> >layAddr: IP.Address=3D3B<B=3D> >R> =3D3B BEGIN<BR> =3D3B =3D3B&=> >nbsp=3D3B IF display =3D3D NIL THEN RETURN=3D> > TRUE=3D3B END=3D3B<BR>> >&=> >nbsp=3D3B =3D3B =3D3B TRY<BR> =3D3B =3D3B =3D3B =3D=> >3B =3D3B IF=3D> > NOT IP.GetHostByName(display=3D2C displayAddr) THEN R=> >ETURN FALSE=3D3B END=3D3B<B=3D> >R> =3D3B =3D3B =3D3B =3D3B=> > =3D3B RETURN displayAddr =3D3D IP.GetHos=3D> >tAddr()=3D3B<BR> =3D=> >3B =3D3B =3D3B EXCEPT<BR> =3D3B =3D3B =3D3B |=3D> > IP.=> >Error =3D3D>=3D3B RETURN FALSE=3D3B<BR> =3D3B =3D3B =3D3B END=> >=3D3B<BR>&=3D> >nbsp=3D3B END SameHost=3D3B<BR>> > =3D3B<BR>> >Thoughts=> >?<BR>> > =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=> >> =3D3B<BR>> >Seems like SocketPosix has nearly the exact same code but=> > appears<BR>more f=3D> >orgiving.. IOError instead of Fatal?<BR>> > =3D=> >3B<BR>> ><BR>SocketPosix.m3:<BR>> > =3D3B<BR>> ><BR>PROCEDURE GetHostAd=> >dr (): Address<BR> =3D3B RAISES {OSError.E} =3D3D<BR=3D> >> =3D3B V=> >AR<BR> =3D3B =3D3B =3D3B host : ARRAY [0..255] OF CHAR=3D3B<=3D=> >> >BR> =3D3B =3D3B =3D3B info : Unetdb.struct_hostent_star=3D3B=> ><BR> =3D> >=3D3B =3D3B =3D3B ua =3D3B =3D3B : Uin.struc=> >t_in_addr=3D3B<BR> =3D3B =3D> >BEGIN<BR> =3D3B =3D3B =3D3B => >IF Unix.gethostname (ADR (host[0])=3D2C BYT=3D> >ESIZE (host)) # 0 THEN<BR>=> > =3D3B =3D3B =3D3B =3D3B =3D3B IOError =3D> >(Unexpecte=> >d)=3D3B<BR> =3D3B =3D3B =3D3B END=3D3B<BR>> > =3D3B =3D=> >3B =3D3B info :=3D3D Unetdb.gethostbyname (ADR (host[0]))=3D3B<=3D> >BR=> >> =3D3B =3D3B =3D3B IF info =3D3D NIL THEN IOError (Unexpected)=> >=3D3B EN=3D> >D=3D3B<BR> =3D3B =3D3B =3D3B <=3D3B* ASSERT inf=> >o.h_length <=3D3B=3D3D BYT=3D> >ESIZE (Address) *>=3D3B<BR>> > =3D3=> >B =3D3B =3D3B ua :=3D3D LOOPHOLE(info.h_addr_list=3D2C<BR> =3D3=> >B&n=3D> >bsp=3D3B =3D3B =3D3B =3D3B =3D3B =3D3B =3D=> >3B =3D3B =3D3B =3D> >=3D3B =3D3B =3D3B =3D3B => >=3D3B =3D3B =3D3B =3D3B UNTRACED REF UN=3D> >TRACED REF Uin.str=> >uct_in_addr)^^=3D3B<BR> =3D3B =3D3B =3D3B RETURN LOOP=3D> >HOLE=> > (ua.s_addr=3D2C Address)=3D3B<BR> =3D3B END GetHostAddr=3D3B<BR>> >&nb=> >sp=3D3B<BR>> > =3D3B<BR>> >It is again disappointing to see such code d=> >uplication.<BR>> > =3D3B<BR>> > =3D3B<BR>> >I guess =3D3BSameHo=> >st can duplicate the logic to predict the error state =3D> >and return fals=> >e =3D3Bupon error?<BR>> >Duplicating the logic for a third time. :(<BR>=> >> > =3D3B<BR>> ><BR> =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>> > =3B<BR>> >PPC_LINUX "just worked"=2C and I can check Solaris and Darwin.<BR>> > =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>> > =3B<BR>> > =3B- Jay<BR><BR><BR>>=3B To: jay.krell at cornell.edu<BR>>=3B Date: S=> >un=2C 11 Jan 2009 08:02:18 -0800<BR>>=3B From: mika at async.caltech.edu<BR>=> >>=3B CC: m3devel at elegosoft.com<BR>>=3B Subject: Re: [M3devel] Juno (X) => >networking problem on AMD64_FREEBSD<BR>>=3B <BR>>=3B This is a screwy t=> >hing in Modula-3. A bug I would call it.<BR>>=3B <BR>>=3B I've noticed => >a lot of networking M3 programs don't work right unless<BR>>=3B the retur=> >n value of Unix's "hostname" maps to a real IP address via<BR>>=3B gethos=> >tbyname. I accomplish it in practice by adding my hostname<BR>>=3B to /et=> >c/hosts.<BR>>=3B <BR>>=3B This is obviously not the right way to fix it=> >... <BR>>=3B <BR>>=3B Mika<BR>>=3B <BR>>=3B Jay writes:<BR>>=3B &=> >gt=3B--_9e67232c-a064-417d-879e-227a77e310f9_<BR>>=3B >=3BContent-Type:=> > text/plain=3B charset=3D"iso-8859-1"<BR>>=3B >=3BContent-Transfer-Enco=> >ding: quoted-printable<BR>>=3B >=3B<BR>>=3B >=3B<BR>>=3B >=3BHi=> >. Unix network programming question..<BR>>=3B >=3BAMD64_FREEBSD:<BR>>=> >=3B >=3B$DISPLAY is set to point back to Cygwin host.It works for PPC_LIN=> >UX.<BR>>=3B >=3B[jay at fbsdamd64a /cm3/bin]$ ./Juno<BR>>=3B >=3B*****=> >* runtime error:*** Exception "IPError.FatalError" not in RAISES li=3D<BR>&=> >gt=3B >=3Bst*** file "../src/common/IPError.m3"=3D2C line 27***<BR>>=3B=> > >=3BAbort trap: 6 (core dumped)[jay at fbsdamd64a /cm3/bin]$<BR>>=3B >=> >=3BIP.m3:<BR>>=3B >=3B=3D20<BR>>=3B >=3BPROCEDURE GetHostAddr(): Ad=> >dress =3D3D VAR hname: ARRAY [0..255] OF CHAR=3D3B =3D<BR>>=3B >=3B BEG=> >IN LOCK mu DO IF Unix.gethostname(ADR(hname[0])=3D2C BYTESIZE(hna=3D<BR>>=> >=3B >=3Bme)) # 0 THEN IPError.Die ()=3D3B END=3D3B VAR h :=3D3D Unetdb.g=> >=3D<BR>>=3B >=3Bethostbyname(ADR(hname[0]))=3D3B BEGIN IF h =3D3D NIL T=> >HEN IPError.Die()=3D<BR>>=3B >=3B=3D3B END=3D3B RETURN GetAddress(h)=3D=> >3B END=3D3B END=3D3B END GetHos=3D<BR>>=3B >=3BtAddr=3D3B<BR>>=3B >=> >=3BPROCEDURE GetAddress (ent: Unetdb.struct_hostent_star): Address =3D3D VA=> >R ua=3D<BR>>=3B >=3B: Uin.struct_in_addr=3D3B BEGIN <=3B* ASSERT ent.=> >h_length <=3B=3D3D BYTESIZE(Addr=3D<BR>>=3B >=3Bess) *>=3B ua :=3D3=> >D LOOPHOLE(ent.h_addr_list=3D2C UNTRACED =3D<BR>>=3B >=3BREF UNTRACED R=> >EF Uin.struct_in_addr)^^=3D3B RETURN LOOPHOLE(ua.s_addr=3D2C A=3D<BR>>=3B=> > >=3Bddress)=3D3B END GetAddress=3D3B<BR>>=3B >=3B=3D20<BR>>=3B >=> >=3Bgethostbyname is failing.<BR>>=3B >=3B=3D20<BR>>=3B >=3BAnalogou=> >s C code also fails:<BR>>=3B >=3B=3D20<BR>>=3B >=3B[jay at fbsdamd64a => >/cm3/bin]$ cat ~/5.c#include <=3Bassert.h>=3B#include <=3Bnetdb.h>=> >=3B#i=3D<BR>>=3B >=3Bnclude <=3Bstdio.h>=3B#include <=3Berrno.h&g=> >t=3Btypedef struct hostent hostent_t=3D3B<BR>>=3B >=3B=3D20<BR>>=3B &=> >gt=3Bint main(){ char hostname[200]=3D3B hostent_t* h=3D3B int i=3D3B<BR>&g=> >t=3B >=3B i =3D3D gethostname(hostname=3D2C 200)=3D3B assert(i =3D3D=3D3D=> > 0)=3D3B printf("hostna=3D<BR>>=3B >=3Bme: %s\n"=3D2C hostname)=3D3B h => >=3D3D gethostbyname(hostname)=3D3B herror("foo")=3D3B=3D<BR>>=3B >=3B p=> >rintf("%p %d %d\n"=3D2C h=3D2C errno=3D2C h_errno)=3D3B assert(h)=3D3B retu=> >rn 0=3D3B}<BR>>=3B >=3B=3D20<BR>>=3B >=3Bherror says "unknown host"=> >.<BR>>=3B >=3BStack is:<BR>>=3B >=3B at ../src/runtime/ex_frame/RTE=> >xFrame.m3:58#13 0x0000000801a7f2b3 in RTH=3D<BR>>=3B >=3Books__Raise (M=> >3_AJWxb1_ex=3D3DError accessing memory address 0x8000ffffd278: =3D<BR>>=> >=3B >=3BBad address.) at ../src/runtime/common/RTHooks.m3:79#14 0x0000000=> >80169c8=3D<BR>>=3B >=3Bd3 in IPError__Die () at ../src/common/IPError.m=> >3:27#15 0x0000000801698a3e =3D<BR>>=3B >=3Bin IP__GetHostAddr (M3_BCxjP=> >n__result=3D3DError accessing memory address 0x80=3D<BR>>=3B >=3B00ffff=> >d338: Bad address.) at ../src/POSIX/IP.m3:82#16 0x00000008012133d0=3D<BR>&g=> >t=3B >=3B in XSharedMem__SameHost (M3_AQuuui_trsl=3D3DError accessing mem=> >ory address 0=3D<BR>>=3B >=3Bx8000ffffd4d8: Bad address.) at ../src/xvb=> >t/XSharedMem.m3:96#17 0x000000=3D<BR>>=3B >=3B0801212ab7 in XSharedMem_=> >_InitXClient (M3_AQuuui_v=3D3DError accessing memory=3D<BR>>=3B >=3B ad=> >dress 0x8000ffffd648: Bad address.) at ../src/xvbt/XSharedMem.m3:29#1=3D<BR=> >>>=3B >=3B8 0x0000000801211819 in XExtensions__InitXClient (M3_AQuuui_x=> >client=3D3DError=3D<BR>>=3B >=3B accessing memory address 0x8000ffffd7f=> >8: Bad address.) at ../src/xvbt/X=3D<BR>>=3B >=3BExtensions.m3:14#19 0x=> >00000008012467a4 in XClientF__Connect (M3_Bd56fi_inst=3D<BR>>=3B >=3B=> >=3D3D0x1879b=3D2C M3_AQuuui_trsl=3D3D0x6) at ../src/xvbt/XClientF.m3:583---=> >Typ=3D<BR>>=3B >=3Be <=3Breturn>=3B to continue=3D2C or q <=3Bret=> >urn>=3B to quit---(More stack frames follow=3D<BR>>=3B >=3B...)(gdb)<=> >BR>>=3B >=3B(* return TRUE if server and client are on same host *)PROC=> >EDURE SameHost (=3D<BR>>=3B >=3Btrsl: XClient.T): BOOLEAN =3D3D VAR dis=> >play :=3D3D DisplayH=3D<BR>>=3B >=3Bost(trsl)=3D3B displayAddr: IP.Addr=> >ess=3D3B BEGIN IF display =3D3D NIL THE=3D<BR>>=3B >=3BN RETURN TRUE=3D=> >3B END=3D3B<BR>>=3B >=3B TRY IF NOT IP.GetHostByName(display=3D2C displ=> >ayAddr) THEN RETURN FA=3D<BR>>=3B >=3BLSE=3D3B END=3D3B RETURN displayA=> >ddr =3D3D IP.GetHostAddr()=3D3B EXCEPT =3D<BR>>=3B >=3B| IP.Error =3D3D=> >>=3B RETURN FALSE=3D3B END=3D3B END SameHost=3D3B<BR>>=3B >=3B=3D20<B=> >R>>=3B >=3BThoughts?<BR>>=3B >=3B=3D20<BR>>=3B >=3BPerhaps my n=> >etwork isn't setup well=3D2C like I should add the local machine =3D<BR>>=> >=3B >=3Bto /etc/hosts.I think this can be made to fail gracefully though.=> >It seems l=3D<BR>>=3B >=3Bike it has nothing to do with AMD64_FREEBSD=> >=3D2C but could have to do with Fr=3D<BR>>=3B >=3BeeBSD.<BR>>=3B >=> >=3B=3D20<BR>>=3B >=3BSeems like SocketPosix has nearly the exact same c=> >ode but appearsmore forgi=3D<BR>>=3B >=3Bving.. IOError instead of Fata=> >l?<BR>>=3B >=3B=3D20<BR>>=3B >=3BSocketPosix.m3:<BR>>=3B >=3B=> >=3D20<BR>>=3B >=3BPROCEDURE GetHostAddr (): Address RAISES {OSError.E} => >=3D3D VAR host : AR=3D<BR>>=3B >=3BRAY [0..255] OF CHAR=3D3B info : Une=> >tdb.struct_hostent_star=3D3B ua : U=3D<BR>>=3B >=3Bin.struct_in_addr=3D=> >3B BEGIN IF Unix.gethostname (ADR (host[0])=3D2C BYTESI=3D<BR>>=3B >=3B=> >ZE (host)) # 0 THEN IOError (Unexpected)=3D3B END=3D3B<BR>>=3B >=3B inf=> >o :=3D3D Unetdb.gethostbyname (ADR (host[0]))=3D3B IF info =3D3D NIL TH=3D<=> >BR>>=3B >=3BEN IOError (Unexpected)=3D3B END=3D3B <=3B* ASSERT info.h=> >_length <=3B=3D3D BYTESIZE =3D<BR>>=3B >=3B(Address) *>=3B<BR>>=> >=3B >=3B ua :=3D3D LOOPHOLE(info.h_addr_list=3D2C UNTRACED REF UNT=3D<BR>=> >>=3B >=3BRACED REF Uin.struct_in_addr)^^=3D3B RETURN LOOPHOLE (ua.s_add=> >r=3D2C Address=3D<BR>>=3B >=3B)=3D3B END GetHostAddr=3D3B<BR>>=3B >=> >=3B=3D20<BR>>=3B >=3B=3D20<BR>>=3B >=3BIt is again disappointing to=> > see such code duplication.<BR>>=3B >=3B=3D20<BR>>=3B >=3B=3D20<BR>=> >>=3B >=3BI guess SameHost can duplicate the logic to predict the error => >state and ret=3D<BR>>=3B >=3Burn false upon error?<BR>>=3B >=3BDupl=> >icating the logic for a third time. :(<BR>>=3B >=3B=3D20<BR>>=3B >=> >=3B - Jay=3D<BR>>=3B >=3B<BR>>=3B >=3B--_9e67232c-a064-417d-879e-22=> >7a77e310f9_<BR>>=3B >=3BContent-Type: text/html=3B charset=3D"iso-8859-=> >1"<BR>>=3B >=3BContent-Transfer-Encoding: quoted-printable<BR>>=3B &g=> >t=3B<BR>>=3B >=3B<=3Bhtml>=3B<BR>>=3B >=3B<=3Bhead>=3B<BR>&=> >gt=3B >=3B<=3Bstyle>=3B<BR>>=3B >=3B.hmmessage P<BR>>=3B >=3B=> >{<BR>>=3B >=3Bmargin:0px=3D3B<BR>>=3B >=3Bpadding:0px<BR>>=3B >=> >=3B}<BR>>=3B >=3Bbody.hmmessage<BR>>=3B >=3B{<BR>>=3B >=3Bfont-=> >size: 10pt=3D3B<BR>>=3B >=3Bfont-family:Verdana<BR>>=3B >=3B}<BR>&g=> >t=3B >=3B<=3B/style>=3B<BR>>=3B >=3B<=3B/head>=3B<BR>>=3B &=> >gt=3B<=3Bbody class=3D3D'hmmessage'>=3B<BR>>=3B >=3BHi. Unix networ=> >k programming question..<=3BBR>=3B<BR>>=3B >=3B<=3BBR>=3BAMD64_=> >FREEBSD:<=3BBR>=3B<BR>>=3B >=3B<=3BBR>=3B$DISPLAY is set to poi=> >nt back to Cygwin host.<=3BBR>=3BIt works for PPC_LINUX=3D<BR>>=3B &g=> >t=3B.<=3BBR>=3B<BR>>=3B >=3B<=3BBR>=3B[jay at fbsdamd64a /cm3/bin]=> >$ ./Juno<=3BBR>=3B<BR>>=3B >=3B<=3BBR>=3B***<=3BBR>=3B*** r=> >untime error:<=3BBR>=3B***&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=> >=3D3B Exception "IPE=3D<BR>>=3B >=3Brror.FatalError" not in RAISES list=> ><=3BBR>=3B***&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B file "..=> >=3D<BR>>=3B >=3B/src/common/IPError.m3"=3D2C line 27<=3BBR>=3B***&l=> >t=3BBR>=3B<BR>>=3B >=3B<=3BBR>=3BAbort trap: 6 (core dumped)<=> >=3BBR>=3B[jay at fbsdamd64a /cm3/bin]$<=3BBR>=3B<BR>>=3B >=3B<=3BB=> >R>=3BIP.m3:<=3BBR>=3B<BR>>=3B >=3B&=3Bnbsp=3D3B<=3BBR>=3B<=> >BR>>=3B >=3BPROCEDURE GetHostAddr(): Address =3D3D<=3BBR>=3B&=3B=> >nbsp=3D3B VAR hname: ARRAY [0..255] =3D<BR>>=3B OF CHAR=3D3B<=3BBR>=> >=3B&=3Bnbsp=3D3B BEGIN<=3BBR>=3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=> >=3Bnbsp=3D3B LOCK mu DO<=3BBR>=3B&=3Bnbs=3D<BR>>=3B >=3Bp=3D3B&a=> >mp=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B IF Unix.geth=> >ostname(ADR(hname[0])=3D2C B=3D<BR>>=3B >=3BYTESIZE(hname)) # 0 THEN<=> >=3BBR>=3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B=> >&=3Bnbsp=3D3B&=3Bnbsp=3D<BR>>=3B >=3B=3D3B&=3Bnbsp=3D3B IPErro=> >r.Die ()=3D3B<=3BBR>=3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B=> >&=3Bnbsp=3D3B&=3Bnbsp=3D3B E=3D<BR>>=3B >=3BND=3D3B<=3BBR>=3B=> >&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=> >=3D3B VAR h :=3D3D Unetdb.gethost=3D<BR>>=3B >=3Bbyname(ADR(hname[0]))=> >=3D3B BEGIN<=3BBR>=3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&a=> >mp=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3B=3D<BR>>=3B >=3Bnbsp=3D3B&=3Bnb=> >sp=3D3B IF h =3D3D NIL THEN IPError.Die()=3D3B END=3D3B<=3BBR>=3B&=> >=3Bnbsp=3D3B&=3Bnbsp=3D<BR>>=3B >=3B=3D3B&=3Bnbsp=3D3B&=3Bnbsp=> >=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B RETURN GetAddress(h)=> >=3D3B<=3BBR>=3B&=3Bnbs=3D<BR>>=3B >=3Bp=3D3B&=3Bnbsp=3D3B&=> >=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B END=3D3B<=3BBR>=3B&=3Bn=> >bsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B END=3D<BR>>=3B >=3B=3D3B<=3B=> >BR>=3B&=3Bnbsp=3D3B END GetHostAddr=3D3B<=3BBR>=3B<BR>>=3B >=> >=3B<=3BBR>=3BPROCEDURE GetAddress (ent: Unetdb.struct_hostent_star): Ad=> >dress =3D3D<=3BBR>=3B=3D<BR>>=3B >=3B&=3Bnbsp=3D3B VAR ua: Uin.s=> >truct_in_addr=3D3B<=3BBR>=3B&=3Bnbsp=3D3B BEGIN<=3BBR>=3B&=3B=> >nbsp=3D3B&=3Bnbsp=3D<BR>>=3B >=3B=3D3B&=3Bnbsp=3D3B &=3Blt=3D3=> >B* ASSERT ent.h_length &=3Blt=3D3B=3D3D BYTESIZE(Address) *&=3Bgt=3D3=> >B=3D<BR>>=3B >=3B<=3BBR>=3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bn=> >bsp=3D3B ua :=3D3D LOOPHOLE(ent.h_addr_list=3D2C<=3BBR>=3B&=3Bnbsp=> >=3D<BR>>=3B >=3B=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&a=> >mp=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=> >=3D3B&=3Bnbsp=3D3B=3D<BR>>=3B >=3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&a=> >mp=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=> >=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B UN=3D<BR>>=3B >=3BTRACED REF UNTR=> ACED REF Uin.struct_in_addr)^^=3D3B<=3BBR>=3B&=3Bnbsp=3D3B&=3Bnbs=> >p=3D3B&=3Bnbsp=3D<BR>>=3B >=3B=3D3B RETURN LOOPHOLE(ua.s_addr=3D2C A=> >ddress)=3D3B<=3BBR>=3B&=3Bnbsp=3D3B END GetAddress=3D3B<=3B=3D<BR>=> >>=3B >=3BBR>=3B<BR>>=3B >=3B&=3Bnbsp=3D3B<=3BBR>=3B<BR>>=> >=3B >=3Bgethostbyname is failing.<=3BBR>=3B<BR>>=3B >=3B<=3BBR&=> >gt=3B&=3Bnbsp=3D3B<=3BBR>=3B<BR>>=3B >=3BAnalogous C code also f=> >ails:<=3BBR>=3B<BR>>=3B >=3B&=3Bnbsp=3D3B<=3BBR>=3B<BR>>=> >=3B >=3B<=3BBR>=3B[jay at fbsdamd64a /cm3/bin]$ cat ~/5.c<=3BBR>=3B#=> >include &=3Blt=3D3Bassert.h&=3Bgt=3D3B<=3BB=3D<BR>>=3B >=3BR>=> >=3B#include &=3Blt=3D3Bnetdb.h&=3Bgt=3D3B<=3BBR>=3B#include &=> >=3Blt=3D3Bstdio.h&=3Bgt=3D3B<=3BBR>=3B#include =3D<BR>>=3B >=3B&=> >amp=3Blt=3D3Berrno.h&=3Bgt=3D3B<=3BBR>=3Btypedef struct hostent host=> >ent_t=3D3B<=3BBR>=3B<BR>>=3B >=3B&=3Bnbsp=3D3B<=3BBR>=3B<BR>=> >>=3B >=3Bint main()<=3BBR>=3B{<=3BBR>=3B&=3Bnbsp=3D3Bchar ho=> >stname[200]=3D3B<=3BBR>=3B&=3Bnbsp=3D3Bhostent_t* h=3D3B=3D<BR>>=> >=3B >=3B<=3BBR>=3B&=3Bnbsp=3D3Bint i=3D3B<=3BBR>=3B<BR>>=3B => >>=3B&=3Bnbsp=3D3Bi =3D3D gethostname(hostname=3D2C 200)=3D3B<=3BBR&g=> >t=3B&=3Bnbsp=3D3Bassert(i =3D3D=3D3D 0)=3D<BR>>=3B >=3B=3D3B<=3BBR=> >>=3B&=3Bnbsp=3D3Bprintf("hostname: %s\n"=3D2C hostname)=3D3B<=3BBR&g=> >t=3B&=3Bnbsp=3D3Bh =3D3D get=3D<BR>>=3B >=3Bhostbyname(hostname)=3D3=> >B<=3BBR>=3B&=3Bnbsp=3D3Bherror("foo")=3D3B<=3BBR>=3B&=3Bnbsp=> >=3D3Bprintf("%p %=3D<BR>>=3B >=3Bd %d\n"=3D2C h=3D2C errno=3D2C h_errno=> >)=3D3B<=3BBR>=3B&=3Bnbsp=3D3Bassert(h)=3D3B<=3BBR>=3B&=3Bnbsp=> >=3D3Bret=3D<BR>>=3B >=3Burn 0=3D3B<=3BBR>=3B}<=3BBR>=3B<BR>>=> >=3B >=3B&=3Bnbsp=3D3B<=3BBR>=3B<BR>>=3B >=3Bherror says "unkno=> >wn host".<=3BBR>=3B<BR>>=3B >=3B<=3BBR>=3BStack is:<=3BBR>=> >=3B<BR>>=3B >=3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B at ../=> >src/runtime/ex_frame/RTExFrame.m3:58<=3BBR>=3B#13 =3D<BR>>=3B >=3B0=> >x0000000801a7f2b3 in RTHooks__Raise (M3_AJWxb1_ex=3D3DError accessing memor=> >y=3D<BR>>=3B >=3B ad<=3BBR>=3Bdress 0x8000ffffd278: Bad address.<=> >=3BBR>=3B)<=3BBR>=3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B => >=3D<BR>>=3B >=3Bat ../src/runtime/common/RTHooks.m3:79<=3BBR>=3B#14=> > 0x000000080169c8d3 in IPError=3D<BR>>=3B >=3B__Die () at ../src/common=> >/IPError.m3:27<=3BBR>=3B#15 0x0000000801698a3e in IP__Ge=3D<BR>>=3B &=> >gt=3BtHostAddr (M3_BCxjPn__result=3D3DError accessing mem<=3BBR>=3Bory => >address 0x8000fff=3D<BR>>=3B >=3Bfd338: Bad address.<=3BBR>=3B)<=> >=3BBR>=3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B at ../src/POSIX=> >/IP.m3:=3D<BR>>=3B >=3B82<=3BBR>=3B#16 0x00000008012133d0 in XShare=> >dMem__SameHost (M3_AQuuui_trsl=3D3DErro=3D<BR>>=3B >=3Br accessing m<=> >=3BBR>=3Bemory address 0x8000ffffd4d8: Bad address.<=3BBR>=3B)<=3BB=> >R>=3B&=3Bnbsp=3D<BR>>=3B >=3B=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B=> > at ../src/xvbt/XSharedMem.m3:96<=3BBR>=3B#17 0x0000000801212a=3D<BR>&g=> >t=3B >=3Bb7 in XSharedMem__InitXClient (M3_AQuuui_v=3D3DError accessing m=> ><=3BBR>=3Bemory add=3D<BR>>=3B >=3Bress 0x8000ffffd648: Bad address=> >.<=3BBR>=3B)<=3BBR>=3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=> >=3D3B at ../sr=3D<BR>>=3B >=3Bc/xvbt/XSharedMem.m3:29<=3BBR>=3B#18 => >0x0000000801211819 in XExtensions__InitXClie=3D<BR>>=3B >=3Bnt (M3_AQuu=> >ui_xclient=3D3DError acce<=3BBR>=3Bssing memory address 0x8000ffffd7f8:=> > =3D<BR>>=3B >=3BBad address.<=3BBR>=3B)<=3BBR>=3B&=3Bnbsp=> >=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B at ../src/xvbt/XExtensions.m3=3D<BR>&=> >gt=3B >=3B:14<=3BBR>=3B#19 0x00000008012467a4 in XClientF__Connect (M=> >3_Bd56fi_inst=3D3D0x1879=3D<BR>>=3B >=3Bb=3D2C<=3BBR>=3B&=3Bnbsp=> >=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B M3_AQuuui_trsl=3D3D0x6) at ../src/xvb=> >t/XClie=3D<BR>>=3B >=3BntF.m3:583<=3BBR>=3B---Type &=3Blt=3D3Bre=> >turn&=3Bgt=3D3B to continue=3D2C or q &=3Blt=3D3Breturn&=3Bg=3D<BR=> >>>=3B >=3Bt=3D3B to quit---<=3BBR>=3B(More stack frames follow...)&=> >lt=3BBR>=3B(gdb)<=3BBR>=3B<BR>>=3B >=3B<=3BBR>=3B(* return TR=> >UE if server and client are on same host *)<=3BBR>=3BPROCEDURE Sa=3D<BR=> >>>=3B >=3BmeHost (trsl: XClient.T): BOOLEAN =3D3D<=3BBR>=3B&=3Bn=> >bsp=3D3B VAR<=3BBR>=3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bn=3D<BR>&g=> >t=3B >=3Bbsp=3D3B display&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B=> >&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=> >=3D<BR>>=3B >=3B=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&a=> >mp=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=> >=3D3B :=3D3D Di=3D<BR>>=3B >=3BsplayHost(trsl)=3D3B<=3BBR>=3B&=> >=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B displayAddr: IP.Address=3D3B&l=> >t=3BB=3D<BR>>=3B >=3BR>=3B&=3Bnbsp=3D3B BEGIN<=3BBR>=3B&=3B=> >nbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B IF display =3D3D NIL THEN RETURN=> >=3D<BR>>=3B >=3B TRUE=3D3B END=3D3B<=3BBR>=3B<BR>>=3B >=3B&=> >=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B TRY<=3BBR>=3B&=3Bnbsp=> >=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B IF=3D=> ><BR>>=3B >=3B NOT IP.GetHostByName(display=3D2C displayAddr) THEN RETUR=> >N FALSE=3D3B END=3D3B<=3BB=3D<BR>>=3B >=3BR>=3B&=3Bnbsp=3D3B&=> >=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B RETURN display=> >Addr =3D3D IP.GetHos=3D<BR>>=3B >=3BtAddr()=3D3B<=3BBR>=3B&=3Bnb=> >sp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B EXCEPT<=3BBR>=3B&=3Bnbsp=3D3=> >B&=3Bnbsp=3D3B&=3Bnbsp=3D3B |=3D<BR>>=3B >=3B IP.Error =3D3D&=> >=3Bgt=3D3B RETURN FALSE=3D3B<=3BBR>=3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=> >amp=3Bnbsp=3D3B END=3D3B<=3BBR>=3B&=3B=3D<BR>>=3B >=3Bnbsp=3D3B => >END SameHost=3D3B<=3BBR>=3B<BR>>=3B >=3B&=3Bnbsp=3D3B<=3BBR>=> >=3B<BR>>=3B >=3BThoughts?<=3BBR>=3B<BR>>=3B >=3B&=3Bnbsp=3D3=> >B<=3BBR>=3B<BR>>=3B >=3B<=3BBR>=3BPerhaps my network isn't setu=> >p well=3D2C like I should add the local mach=3D<BR>>=3B >=3Bine to /etc=> >/hosts.<=3BBR>=3BI think this can be made to fail gracefully though.<=> >=3BB=3D<BR>>=3B >=3BR>=3BIt seems like it has nothing to do with AMD6=> >4_FREEBSD=3D2C but could have t=3D<BR>>=3B >=3Bo do with FreeBSD.<=3B=> >BR>=3B<BR>>=3B >=3B<=3BBR>=3B&=3Bnbsp=3D3B<=3BBR>=3B<BR>&g=> >t=3B >=3BSeems like SocketPosix has nearly the exact same code but appear=> >s<=3BBR>=3Bmore f=3D<BR>>=3B >=3Borgiving.. IOError instead of Fata=> >l?<=3BBR>=3B<BR>>=3B >=3B&=3Bnbsp=3D3B<=3BBR>=3B<BR>>=3B &=> >gt=3B<=3BBR>=3BSocketPosix.m3:<=3BBR>=3B<BR>>=3B >=3B&=3Bnbs=> >p=3D3B<=3BBR>=3B<BR>>=3B >=3B<=3BBR>=3BPROCEDURE GetHostAddr ()=> >: Address<=3BBR>=3B&=3Bnbsp=3D3B RAISES {OSError.E} =3D3D<=3BBR=3D=> ><BR>>=3B >=3B>=3B&=3Bnbsp=3D3B VAR<=3BBR>=3B&=3Bnbsp=3D3B&a=> >mp=3Bnbsp=3D3B&=3Bnbsp=3D3B host : ARRAY [0..255] OF CHAR=3D3B<=3B=3D<=> >BR>>=3B >=3BBR>=3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B in=> >fo : Unetdb.struct_hostent_star=3D3B<=3BBR>=3B&=3Bnbsp=3D<BR>>=3B => >>=3B=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B ua&=3Bnbsp=3D3B&=3Bnbsp=> >=3D3B : Uin.struct_in_addr=3D3B<=3BBR>=3B&=3Bnbsp=3D3B =3D<BR>>=3B=> > >=3BBEGIN<=3BBR>=3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B => >IF Unix.gethostname (ADR (host[0])=3D2C BYT=3D<BR>>=3B >=3BESIZE (host)=> >) # 0 THEN<=3BBR>=3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&am=> >p=3Bnbsp=3D3B&=3Bnbsp=3D3B IOError =3D<BR>>=3B >=3B(Unexpected)=3D3B=> ><=3BBR>=3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B END=3D3B<=> >=3BBR>=3B<BR>>=3B >=3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3=> >B info :=3D3D Unetdb.gethostbyname (ADR (host[0]))=3D3B<=3B=3D<BR>>=3B => >>=3BBR>=3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B IF info =3D3=> >D NIL THEN IOError (Unexpected)=3D3B EN=3D<BR>>=3B >=3BD=3D3B<=3BBR&g=> >t=3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B &=3Blt=3D3B* ASSERT=> > info.h_length &=3Blt=3D3B=3D3D BYT=3D<BR>>=3B >=3BESIZE (Address) *=> >&=3Bgt=3D3B<=3BBR>=3B<BR>>=3B >=3B&=3Bnbsp=3D3B&=3Bnbsp=3D=> >3B&=3Bnbsp=3D3B ua :=3D3D LOOPHOLE(info.h_addr_list=3D2C<=3BBR>=3B&a=> >mp=3Bnbsp=3D3B&=3Bn=3D<BR>>=3B >=3Bbsp=3D3B&=3Bnbsp=3D3B&=3Bnb=> >sp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=> >=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D<BR>>=3B >=3B=3D3B&=3Bnbsp=> >=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&=> >=3Bnbsp=3D3B&=3Bnbsp=3D3B UNTRACED REF UN=3D<BR>>=3B >=3BTRACED REF => >Uin.struct_in_addr)^^=3D3B<=3BBR>=3B&=3Bnbsp=3D3B&=3Bnbsp=3D3B&am=> >p=3Bnbsp=3D3B RETURN LOOP=3D<BR>>=3B >=3BHOLE (ua.s_addr=3D2C Address)=> >=3D3B<=3BBR>=3B&=3Bnbsp=3D3B END GetHostAddr=3D3B<=3BBR>=3B<BR>&=> >gt=3B >=3B&=3Bnbsp=3D3B<=3BBR>=3B<BR>>=3B >=3B&=3Bnbsp=3D3B=> ><=3BBR>=3B<BR>>=3B >=3BIt is again disappointing to see such code d=> >uplication.<=3BBR>=3B<BR>>=3B >=3B&=3Bnbsp=3D3B<=3BBR>=3B<BR=> >>>=3B >=3B&=3Bnbsp=3D3B<=3BBR>=3B<BR>>=3B >=3BI guess&=3B=> >nbsp=3D3BSameHost can duplicate the logic to predict the error state =3D<BR=> >>>=3B >=3Band return false&=3Bnbsp=3D3Bupon error?<=3BBR>=3B<BR>=> >>=3B >=3BDuplicating the logic for a third time. :(<=3BBR>=3B<BR>&g=> >t=3B >=3B&=3Bnbsp=3D3B<=3BBR>=3B<BR>>=3B >=3B<=3BBR>=3B&am=> >p=3Bnbsp=3D3B- Jay<=3BBR>=3B<=3BBR>=3B<=3B/body>=3B<BR>>=3B &=> >gt=3B<=3B/html>=3B=3D<BR>>=3B >=3B<BR>>=3B >=3B--_9e67232c-a064=> >-417d-879e-227a77e310f9_--<BR><BR></body>> ></html>=> >> >--_b00371fe-730b-4981-9051-a874361296d7_--
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20090112/e895792f/attachment-0002.html>
More information about the M3devel
mailing list