Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: TestDialError fails #35

Closed
gopherbot opened this issue Nov 11, 2009 · 1 comment
Closed

net: TestDialError fails #35

gopherbot opened this issue Nov 11, 2009 · 1 comment
Milestone

Comments

@gopherbot
Copy link

by nick.fa.jones:

What steps will reproduce the problem?
1. all.bash


What is the expected output? What do you see instead?
expected:
PASS, nick, you are so cool

got:
nick@nickhq3:~/src/go/src/pkg/net$ make test
gotest
make[1]: Entering directory `/home/nick/src/go/src/pkg/net'
rm -f _test/net.a _gotest_.6
make[1]: Leaving directory `/home/nick/src/go/src/pkg/net'
make[1]: Entering directory `/home/nick/src/go/src/pkg/net'
6g -o _gotest_.6 dnsclient.go dnsconfig.go dnsmsg.go fd.go fd_linux.go 
ip.go ipsock.go net.go parse.go port.go sock.go tcpsock.go udpsock.go 
unixsock.go    dialgoogle_test.go ip_test.go net_test.go parse_test.go 
port_test.go server_test.go timeout_test.go
rm -f _test/net.a
gopack grc _test/net.a _gotest_.6
make[1]: Leaving directory `/home/nick/src/go/src/pkg/net'
throw: index out of range

panic PC=0x2b3ded88cd38
throw+0x3e /home/nick/src/go/src/pkg/runtime/runtime.c:74
        throw(0x47f060, 0x0)
runtime·throwindex+0x1c /home/nick/src/go/src/pkg/runtime/runtime.c:47
        runtime·throwindex()
net·hostPortToIP+0x19a /home/nick/src/go/src/pkg/net/ipsock.go:199
        net·hostPortToIP(0x446170, 0x0, 0x3, 0x0, 0x464280, ...)
net·ResolveTCPAddr+0x34 /home/nick/src/go/src/pkg/net/tcpsock.go:61
        net·ResolveTCPAddr(0x464280, 0x0, 0xf, 0x0, 0x4462f0, ...)
net·Dial+0x2a3 /home/nick/src/go/src/pkg/net/net.go:133
        net·Dial(0x446170, 0x0, 0x3, 0x0, 0x4462f0, ...)
net·TestDialError+0xbc /home/nick/src/go/src/pkg/net/net_test.go:56
        net·TestDialError(0xed8c3ba0, 0x2b3d)
testing·tRunner+0x22 /home/nick/src/go/src/pkg/testing/testing.go:105
        testing·tRunner(0xed8c3ba0, 0x2b3d, 0x494a28, 0x0)
goexit /home/nick/src/go/src/pkg/runtime/proc.c:134
        goexit()
0x2b3ded8c3ba0 unknown pc

goroutine 3:
runtime·entersyscall+0x50 /home/nick/src/go/src/pkg/runtime/proc.c:539
        runtime·entersyscall()
syscall·Syscall6+0x5 /home/nick/src/go/src/pkg/syscall/asm_linux_amd64.s:41
        syscall·Syscall6()
syscall·EpollWait+0x84 /home/nick/src/go/src/pkg/syscall/
zsyscall_linux_amd64.go:132
        syscall·EpollWait(0x6, 0x2b3d, 0xed8c5280, 0x2b3d, 0x1, ...)
net·*pollster·WaitFD+0xb5 /home/nick/src/go/src/pkg/net/fd_linux.go:116
        net·*pollster·WaitFD(0xed886ca0, 0x2b3d, 0x39cf6c58, 0x0, 
0x72, ...)
net·*pollServer·Run+0x9e /home/nick/src/go/src/pkg/net/fd.go:237
        net·*pollServer·Run(0xed848680, 0x2b3d)
goexit /home/nick/src/go/src/pkg/runtime/proc.c:134
        goexit()
0x2b3ded848680 unknown pc

goroutine 1:
gosched+0x34 /home/nick/src/go/src/pkg/runtime/proc.c:515
        gosched()
chanrecv+0x318 /home/nick/src/go/src/pkg/runtime/chan.c:319
        chanrecv(0xed8e1a00, 0x2b3d, 0xed88bf68, 0x2b3d, 0x0, ...)
runtime·chanrecv1+0x50 /home/nick/src/go/src/pkg/runtime/chan.c:415
        runtime·chanrecv1(0xed8e1a00, 0x2b3d)
testing·Main+0x263 /home/nick/src/go/src/pkg/testing/testing.go:132
        testing·Main(0x4949f8, 0x0)
main·main+0x23 /home/nick/src/go/src/pkg/net/_testmain.go:21
        main·main()
mainstart+0xf /home/nick/src/go/src/pkg/runtime/amd64/asm.s:55
        mainstart()
goexit /home/nick/src/go/src/pkg/runtime/proc.c:134
        goexit()
make: *** [test] Error 2, nick, you suck


What is your $GOOS?  $GOARCH?
GOARCH=amd64
GOOS=linux


Which revision are you sync'ed to?  (hg log -l 1)
changeset:   3975:b51fd2d6c160
tag:         tip
user:        Kevin Ballard <kevin@sb.org>
date:        Tue Nov 10 20:05:24 2009 -0800
summary:     Implement new emacs command M-x gofmt


Please provide any additional information below.
net_test #4 seems to be testing the domain suffix search list feature, 
recorded by the _DNS_Config structure and used by the net.LookupHost 
function.  It uses a hostname with no internal or trailing dots, and 
expects a failed result containing the same hostname followed by a dot, 
then a domain consisting of zero (:O) or more characters, then another dot 
followed by an error message.

If the local machine is set up with NO domain suffixes configured, then 
net_test #4 fails (in various ways described below)

The failure may or may not be fixed (described below also), but to get to 
the point, net.LookupHost needs a fix, and so does the test.  Perhaps the 
best way to fix the test, and retain its relevance, is to temporary add 
domain a suffix search entry, such as '.localdomain', to the runtime 
_DNS_Config only for the duration of test #4 if there were no suffixes 
(suffixe??? suffii???) already discovered.

The first way that the test fails is quoted above.

The function net.hostPortToIP (ipsock.go:199) assumes that the addrs array 
returned by net.LookupHost will always have length > 0 if there was no 
error, but net.LookupHost can indeed return in this state.

If the host parameter contains no dot, either internally, or as the last 
character (FQDN), and the host machine has no domain suffix search list 
configured, then this parameter will pass through net.LookupHost without 
any lookup being done on it, thus addrs and err will not be set.

The version of net.LookupHost in revision control behavies like this, but 
the version at: http://golang.org/src/pkg/net/dnsclient.go seems to work 
around this same issue with an attempt at a final, unavioudable lookup of 
the hostname with a '.' appended.  I'm not sure which version is more up 
to date, but the fix in the version of dnsclient.go from the website 
(actually both versions) is missing a step.

Should there not be a local lookup of hostnames on the host machine, ie, /
etc/hosts ?  This is usually done as a first step in a number of resolvers 
(like c-ares, doesn't google use c-ares?), and is the default setting for 
the libc resolver on most linuxes (linuxe??! linii?!!). Appending the dot 
to the dotless/trailingdotless hostname is only valid as a last resort if 
the local lookup has already been performed.

The second way that the test fails (using the fix from the web version of 
dnsclient.go), is the error string returned by net.LookupHost still 
doesn't match the pattern expected by net_test #4 (it doesn't contain a 
domain).  To fix this, net_test #4 could be changed as explained above, to 
temporarily add one '.localdomain' entry (or even many, to further test 
the code) to an empty domain suffix search list for the duration of the 
test, so that the test remains relevant and covers the code paths it is 
intended to cover.
@rsc
Copy link
Contributor

rsc commented Nov 11, 2009

Comment 1:

This test is now disabled from the default build.
hg pull
hg update release
should get you to a point where this test does not run.

Status changed to Fixed.

minux added a commit to minux/goios that referenced this issue Feb 27, 2015
It brings the assembler in line with 5a and 9a.

Fixes golang#35.

Signed-off-by: minux <minux@golang.org>
@mikioh mikioh changed the title net_test #4 fails net: TestDialError fails Aug 5, 2015
@mikioh mikioh added this to the Go1.5 milestone Aug 5, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants