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: ListenMulticastUDP on <nil> failed #6159

Closed
gopherbot opened this issue Aug 15, 2013 · 14 comments
Closed

net: ListenMulticastUDP on <nil> failed #6159

gopherbot opened this issue Aug 15, 2013 · 14 comments
Milestone

Comments

@gopherbot
Copy link

by atkaaz:

Before filing a bug, please check whether it has been fixed since the
latest release. Search the issue tracker and check that you're running the
latest version of Go:

Run "go version" and compare against
http://golang.org/doc/devel/release.html  If a newer version of Go exists,
install it and retry what you did to reproduce the problem.

Thanks.

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. checkout latest go from repository
2. cd src
set GOARCH=amd64
set GOOS=windows
call all.bat

Subsequently, just running this: 
go test std -short -timeout=120s
would work, without recompiling everything


What is the expected output?
ok      mime/multipart  0.863s
ok      net     2.725s
ok      net/http        5.568s

What do you see instead?
ok      mime/multipart  0.863s
--- FAIL: TestIPv4MulticastListener (0.02 seconds)
        multicast_test.go:53: First ListenMulticastUDP on <nil> failed: listen udp 224.0.0.254: set
sockopt: An unknown, invalid, or unsupported option or level was specified in a
getsockopt or setso
ckopt call.
FAIL
FAIL    net     3.160s
ok      net/http        5.568s

Which compiler are you using (5g, 6g, 8g, gccgo)?
?

Which operating system are you using?
Windows 7 64bit

Which version are you using?  (run 'go version')
go version devel +749d02164043 Thu Aug 15 14:38:32 2013 -0400 windows/amd64

Please provide any additional information below.
http://code.google.com/p/go/source/detail?r=749d021640436ab33eb8dfdb25bbec472e80af73

It's possible this fails for me and only for me because possibly I've disabled some
things in this system (but can't remember what and where but ie. maybe multicast is
disabled?, but it's not because the firewall is silently blocking it(without logging)
because I've disabled the firewall and still happens)

Also note that if PeerBlock is enabled (some 3rd party program) then it will block
(TCP)packets to destination 127.0.71.111 and will thus cause another fail to happen:
--- FAIL: TestDialTimeout (0.01 seconds)
        dial_test.go:104: got error "dial tcp 127.0.71.111:49151: ConnectEx tcp: An attempt was made to access a socket in a way forbidden by its access permissions."; not a timeout

But this doesn't matter for me because I've disabled PeerBlock during the test(s).
@robpike
Copy link
Contributor

robpike commented Aug 15, 2013

Comment 1:

Looks windows-specific. Correct labels if not.

Labels changed: added priority-later, os-windows, removed priority-triage.

Status changed to Accepted.

@alexbrainman
Copy link
Member

Comment 2:

atkaaz,
Looking at your error, it is hard for us to see where in ListenMulticastUDP it fails,
but you should be able to determine it easy enough. Just add println or fmt.Printf in
the source to see where the calls go and report back where it fails.
Thank you.
Alex

@gopherbot
Copy link
Author

Comment 3 by atkaaz:

I like that attitude. Surely enough, I'll do so.
I've tracked it until it says import cycle not allowed (in 2 places)
http://code.google.com/p/go/source/browse/src/pkg/net/udpsock_posix.go#230
which means that err is not nil here:
http://code.google.com/p/go/source/browse/src/pkg/net/udpsock_posix.go#228
and going inside this one(listenIPv4MulticastUDP):
http://code.google.com/p/go/source/browse/src/pkg/net/udpsock_posix.go#251
which means: http://code.google.com/p/go/source/browse/src/pkg/net/udpsock_posix.go#250
joinIPv4Group err isn't nil, so going inside this one(joinIPv4Group):
http://code.google.com/p/go/source/browse/src/pkg/net/sockoptip_posix.go#23
and from here on I couldn't track due to import "fmt" cycle
The two (more) relevant lines from the last line above are:
http://code.google.com/p/go/source/browse/src/pkg/os/error.go#39
http://code.google.com/p/go/source/browse/src/pkg/syscall/syscall_windows.go#871
Actually, I don't know why I disregarded using just "println" when reading what you
said, and I used fmt.Println instead. Looks like with "println" I can avoid import
cycle, however I notice that using println in error.go causes it to print many lines AND
they intermix with each other sometimes and looks like this:
d1
d2
d1d1
d2
d2
d1
Any thoughts on this part? Looks like the same println line(and the next line) can get
between the printed text and its newline(also replaced all fmt.Println with println just
in case), code is like this:
func NewSyscallError(syscall string, err error) error {
    println("d1")
    if err == nil {
        println("d2")
        return nil
    }
    println("d3")
    return &SyscallError{syscall, err}
}
(but this d1 and d2 only happens after the fail is reported (and also at this line
before the fail is reported:
http://code.google.com/p/go/source/browse/src/pkg/net/udpsock_posix.go#247  but this is
NOT relevant to this issue, because d1 d3 happens at our joinIPv4Group line below that) )

@alexbrainman
Copy link
Member

Comment 4:

Well done.
So, I take it call to syscall.SetsockoptIPMreq in
https://code.google.com/p/go/source/browse/src/pkg/net/sockoptip_posix.go#23 fails.
Right? (you can split the line - put call on a separate line and capture returned error
and check it before passing it into os.NewSyscallError function)
Also googling for your error "an unknown invalid or unsupported option or level was
specified in a getsockopt or setsockopt call", it seems it is WSAENOPROTOOPT.
So syscall.SetsockoptIPMreq Windows API fails with error WSAENOPROTOOPT. Unfortunately,
I don't know much about all this network stuff, but mikio might know. Lets wait for him
to comment.
Alex

@gopherbot
Copy link
Author

Comment 5 by atkaaz:

Thx, new to Go.
Rightly so:
I did this:
a := syscall.SetsockoptIPMreq(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_ADD_MEMBERSHIP,
mreq)
println("b8 ", a)
which prints:
b8  (0x140028,0x273a)
that 0x273a is WSAENOPROTOOPT (as you said) 
 Winsock error 10042  (0x273A in hex)
WSAENOPROTOOPT  -  Bad protocol option. 
There's this text here: http://support.microsoft.com/kb/131978
"
If a multicast datagram is sent to a group to which the sending host itself belongs (on
the outgoing interface), by default, a copy of the datagram is looped back by the IP
layer for local delivery. Under some versions of UNIX, there is an option available to
disable this behavior (IP_MULTICAST_LOOP). This option is not supported in Windows NT.
If you try to disable this behavior, the call fails with the error WSAENOPROTOOPT (Bad
protocol option). 
"
The last phrase makes me believe that the error must happen because I've somehow
disabled multicast in my OS (I can't remember if I did or how, but it's quite likely
that I did it some time ago)
If this is so, I wonder if there's something that can be done so the test doesn't fail
or something(maybe say that it could be because multicast is disabled in OS)... which
prevents go getting installed at the end of tests (surely I am using make.bat which
skips tests, to have go install, as a workaround so far)
I just looked and can confirm that IGMPLevel is set to 0 for me, that means No multicast
support.
http://technet.microsoft.com/en-us/library/cc957547.aspx
I'll do a reboot and see if it works with IGMPLevel 2

@alexbrainman
Copy link
Member

Comment 6:

make.bat installs go (builds it from source and installs compiled binaries into
appropriate places).
all.bat runs make.bat + runs all tests to make sure your system is suitable for Go
development. You don't really need to run tests, if you just want to install Go. Of
course, as you discovered, skipping tests means that some functions might not work as
advertised.
You can also skip tests selectively by renaming the function - all tests must start with
Test. So, if you rename TestIPv4MulticastListener to testIPv4MulticastListener or
similar, all.bat will not run this test.
Alex

@gopherbot
Copy link
Author

Comment 7 by atkaaz:

Yep, totally works with IGMPLevel 2 (maybe with 1 also, but didn't yet test, should I?)
So when IGMPLevel is 0 (aka disabled) it will fail like that.
Fri 08/16/2013  5:36:47.66 s:\workspace.go.2013\go\src>go test net -short
ok      net     2.546s
that is:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\
REG_WORD (32bit value) IGMPLevel
2
I should note that although IGMP was enabled, my firewall still blocked all IGMP packets.
There are some things to note while I was trying this, if I don't append "-short" to `go
test net` command then it panics like so:
Fri 08/16/2013  5:43:31.63 s:\workspace.go.2013\go\src>go test net
--- FAIL: TestDialGoogleIPv4 (0.02 seconds)
        dialgoogle_test.go:66: lookup www.google.com: GetAddrInfoW: No such host is known.
--- FAIL: TestGoogleSRV (0.01 seconds)
        lookup_test.go:24: failed: LookupSRV: No DNS servers configured for local system.
        lookup_test.go:27: no results
        lookup_test.go:33: back door failed: LookupSRV: No DNS servers configured for local system.
        lookup_test.go:36: back door no results
--- FAIL: TestGmailMX (0.00 seconds)
        lookup_test.go:46: failed: LookupMX: No DNS servers configured for local system.
        lookup_test.go:49: no results
--- FAIL: TestGmailNS (0.00 seconds)
        lookup_test.go:59: failed: LookupNS: No DNS servers configured for local system.
        lookup_test.go:62: no results
--- FAIL: TestGmailTXT (0.00 seconds)
        lookup_test.go:72: failed: LookupTXT: No DNS servers configured for local system.
        lookup_test.go:75: no results
--- FAIL: TestGoogleDNSAddr (0.02 seconds)
        lookup_test.go:85: failed: LookupAddr: No DNS servers configured for local system.
        lookup_test.go:88: no results
--- FAIL: TestLookupIANACNAME (0.00 seconds)
        lookup_test.go:98: LookupCNAME("www.iana.org.") = "", LookupCNAME: No DNS servers configure
d for local system., want "*.icann.org.", nil
here1
here2
here4
here6
a1
a4
a6
b1
b2
b4
b6
b7  12
f1
b8  (0x0,0x0)
a8
here8
herec
here1
here2
here4
here6
a1
a4
a6
b1
b2
b4
b6
b7  12
f1
b8  (0x0,0x0)
a8
here8
herec
here1
here2
here4
here6
a1
a4
a6
b1
b2
b4
b6
b7  12
f1
b8  (0x0,0x0)
a8
here8
herec
here1
here2
here4
here6
a1
a4
a6
b1
b2
b4
b6
b7  12
f1
b8  (0x0,0x0)
a8
here8
herec
here1
here2
here4
here6
a1
a4
a6
b1
b2
b4
b6
b7  12
f1
b8  (0x0,0x0)
a8
here8
herec
here1
here2
here4
here6
a1
a4
a6
b1
b2
b4
b6
b7  12
f1
b8  (0x0,0x0)
a8
here8
herec
here1
here2
here4
here6
a1
a4
a6
b1
b2
b4
b6
b7  12
f1
b8  (0x0,0x0)
a8
here8
herec
here1
here2
here4
here6
a1
a4
a6
b1
b2
b4
b6
b7  12
f1
b8  (0x0,0x0)
a8
here8
herec
--- FAIL: TestDualStackUDPListener (0.00 seconds)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x1 addr=0x0 pc=0x4ae960]
goroutine 456 [running]:
testing.func·005()
        s:/workspace.go.2013/go/src/pkg/testing/testing.go:382 +0x107
net.checkDualStackSecondListener(0xc084095c60, 0x61a100, 0x3, 0xc084098348, 0x6, ...)
        C:/Go/src/pkg/net/unicast_posix_test.go:357 +0x640
net.TestDualStackUDPListener(0xc084095c60)
        C:/Go/src/pkg/net/unicast_posix_test.go:241 +0x770
testing.tRunner(0xc084095c60, 0x8197c8)
        s:/workspace.go.2013/go/src/pkg/testing/testing.go:387 +0xaa
created by testing.RunTests
        s:/workspace.go.2013/go/src/pkg/testing/testing.go:467 +0x917
goroutine 1 [chan receive]:
testing.RunTests(0x673fb0, 0x818e20, 0x6a, 0x6a, 0xc084002f00)
        s:/workspace.go.2013/go/src/pkg/testing/testing.go:468 +0x944
testing.Main(0x673fb0, 0x818e20, 0x6a, 0x6a, 0x812120, ...)
        s:/workspace.go.2013/go/src/pkg/testing/testing.go:399 +0x99
main.main()
        net/_test/_testmain.go:291 +0x9f
goroutine 186 [chan send]:
net.func·090()
        C:/Go/src/pkg/net/timeout_test.go:167 +0xa5
created by net.TestWriteTimeout
        C:/Go/src/pkg/net/timeout_test.go:170 +0x6ab
goroutine 188 [chan send]:
net.runDatagramPacketConnServer(0xc084095cf0, 0x61a100, 0x3, 0x61d430, 0xb, ...)
        C:/Go/src/pkg/net/server_test.go:392 +0x4e3
created by net.TestTimeoutUDP
        C:/Go/src/pkg/net/timeout_test.go:244 +0x1d9
FAIL    net     25.290s
(tested the above with internet cable disconnected, but the same panic happens with
internet connected but still I am not allowing net.test.exe in firewall to go out)
Also, at one time it never exited(and didn't print anything on console) so I had to kill
go.exe and I notice net.test.exe is there in taskmanager and I am unable to kill it
(Access is denied, although I'm admin user)
tried the above with:
go version devel +8345604e9545 Thu Aug 15 22:37:16 2013 -0400 windows/amd64
after actually cleaning my modified files (the ones with println in them, via hg update
-C so discarding any modified files) and recompiling with all.bat
Everything worked calling all.bat ("ALL TESTS PASSED"), there were no test errors even
though I did block some http.test.exe and that test seems to have taken only 18 seconds
but still passed (wondering if something similar can be done for this current issue, for
when IGMP is disabled in OS, because I assume it's analogous to http.test.exe when it
doesn't have internet access)
After this, doing `go test net` (without `-short`) shows this then:
Fri 08/16/2013  5:58:06.93 s:\workspace.go.2013\go\src>go test net
--- FAIL: TestDialGoogleIPv4 (12.03 seconds)
        dialgoogle_test.go:66: lookup www.google.com: GetAddrInfoW: No such host is known.
--- FAIL: TestGoogleSRV (0.00 seconds)
        lookup_test.go:24: failed: LookupSRV: This operation returned because the timeout period ex
pired.
        lookup_test.go:27: no results
        lookup_test.go:33: back door failed: LookupSRV: This operation returned because the timeout
 period expired.
        lookup_test.go:36: back door no results
--- FAIL: TestGmailMX (0.00 seconds)
        lookup_test.go:46: failed: LookupMX: This operation returned because the timeout period exp
ired.
        lookup_test.go:49: no results
--- FAIL: TestGmailNS (0.00 seconds)
        lookup_test.go:59: failed: LookupNS: This operation returned because the timeout period exp
ired.
        lookup_test.go:62: no results
--- FAIL: TestGmailTXT (0.00 seconds)
        lookup_test.go:72: failed: LookupTXT: This operation returned because the timeout period ex
pired.
        lookup_test.go:75: no results
--- FAIL: TestGoogleDNSAddr (0.00 seconds)
        lookup_test.go:85: failed: LookupAddr: This operation returned because the timeout period e
xpired.
        lookup_test.go:88: no results
--- FAIL: TestLookupIANACNAME (0.00 seconds)
        lookup_test.go:98: LookupCNAME("www.iana.org.") = "", LookupCNAME: This operation returned
because the timeout period expired., want "*.icann.org.", nil
--- FAIL: TestDualStackUDPListener (0.00 seconds)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x1 addr=0x0 pc=0x4ae460]
goroutine 456 [running]:
testing.func·005()
        s:/workspace.go.2013/go/src/pkg/testing/testing.go:382 +0x107
net.checkDualStackSecondListener(0xc0840a6d80, 0x619880, 0x3, 0xc084104740, 0x6, ...)
        C:/Go/src/pkg/net/unicast_posix_test.go:357 +0x640
net.TestDualStackUDPListener(0xc0840a6d80)
        C:/Go/src/pkg/net/unicast_posix_test.go:241 +0x770
testing.tRunner(0xc0840a6d80, 0x8197c8)
        s:/workspace.go.2013/go/src/pkg/testing/testing.go:387 +0xaa
created by testing.RunTests
        s:/workspace.go.2013/go/src/pkg/testing/testing.go:467 +0x917
goroutine 1 [chan receive]:
testing.RunTests(0x673730, 0x818e20, 0x6a, 0x6a, 0xc084002f00)
        s:/workspace.go.2013/go/src/pkg/testing/testing.go:468 +0x944
testing.Main(0x673730, 0x818e20, 0x6a, 0x6a, 0x812120, ...)
        s:/workspace.go.2013/go/src/pkg/testing/testing.go:399 +0x99
main.main()
        net/_test/_testmain.go:291 +0x9f
goroutine 188 [chan send]:
net.runDatagramPacketConnServer(0xc0840a6120, 0x619880, 0x3, 0x61cbb0, 0xb, ...)
        C:/Go/src/pkg/net/server_test.go:392 +0x4e3
created by net.TestTimeoutUDP
        C:/Go/src/pkg/net/timeout_test.go:244 +0x1d9
goroutine 186 [chan send]:
net.func·090()
        C:/Go/src/pkg/net/timeout_test.go:167 +0xa5
created by net.TestWriteTimeout
        C:/Go/src/pkg/net/timeout_test.go:170 +0x6ab
FAIL    net     35.937s
(note that, I had internet cable in but blocked net.test.exe from accessing the
internet, via firewall)

@gopherbot
Copy link
Author

Comment 8 by atkaaz:

Thank you, Alex.

@gopherbot
Copy link
Author

Comment 9 by atkaaz:

For consistency's sake, I tried `go test net` and allowed net.test.exe access to
internet:
first try it hung and I couldn't kill net.test.exe (again with access denied from task
manager) but I could kill go, and second try is the panic, here's both cases:
Fri 08/16/2013  6:01:24.71 s:\workspace.go.2013\go\src>go test net
Fri 08/16/2013  6:07:06.64 s:\workspace.go.2013\go\src>go test net
--- FAIL: TestDualStackUDPListener (0.00 seconds)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x1 addr=0x0 pc=0x4ae460]
goroutine 456 [running]:
testing.func·005()
        s:/workspace.go.2013/go/src/pkg/testing/testing.go:382 +0x107
net.checkDualStackSecondListener(0xc0840a95a0, 0x619880, 0x3, 0xc08407c7e0, 0x6, ...)
        C:/Go/src/pkg/net/unicast_posix_test.go:357 +0x640
net.TestDualStackUDPListener(0xc0840a95a0)
        C:/Go/src/pkg/net/unicast_posix_test.go:241 +0x770
testing.tRunner(0xc0840a95a0, 0x8197c8)
        s:/workspace.go.2013/go/src/pkg/testing/testing.go:387 +0xaa
created by testing.RunTests
        s:/workspace.go.2013/go/src/pkg/testing/testing.go:467 +0x917
goroutine 1 [chan receive]:
testing.RunTests(0x673730, 0x818e20, 0x6a, 0x6a, 0xc084002f01)
        s:/workspace.go.2013/go/src/pkg/testing/testing.go:468 +0x944
testing.Main(0x673730, 0x818e20, 0x6a, 0x6a, 0x812120, ...)
        s:/workspace.go.2013/go/src/pkg/testing/testing.go:399 +0x99
main.main()
        net/_test/_testmain.go:291 +0x9f
goroutine 188 [chan send]:
net.runDatagramPacketConnServer(0xc0840a9b40, 0x619880, 0x3, 0x61cbb0, 0xb, ...)
        C:/Go/src/pkg/net/server_test.go:392 +0x4e3
created by net.TestTimeoutUDP
        C:/Go/src/pkg/net/timeout_test.go:244 +0x1d9
goroutine 186 [chan send]:
net.func·090()
        C:/Go/src/pkg/net/timeout_test.go:167 +0xa5
created by net.TestWriteTimeout
        C:/Go/src/pkg/net/timeout_test.go:170 +0x6ab
FAIL    net     26.755s

@alexbrainman
Copy link
Member

Comment 10:

> first try it hung and I couldn't kill net.test.exe (again with access denied from task
manager) ...
Very strange. Do you have an antivirus? Or maybe "just in time debugger"?
...
net.checkDualStackSecondListener(0xc0840a95a0, 0x619880, 0x3, 0xc08407c7e0, 0x6, ...)
        C:/Go/src/pkg/net/unicast_posix_test.go:357 +0x640
...
it is trying to dereference l variable (it will have nil in it). That is a bug in test.
Alex

@gopherbot
Copy link
Author

Comment 11 by atkaaz:

I don't have an antivirus, but not sure about the jit debugger (maybe there's one that I
don't know of?) I only have the firewall part of comodo (with defense+ disabled - this
could've qualified(maybe?) as a debugger of some kind if it weren't permanently disabled
which required a restart when I did it, long ago)
I've also encountered the hang just now with `go test net -short` (can't kill
net.test.exe again)
trying with PeerBlock disabled and firewall enabled, it doesn't seem to hang so far WHEN
internet cable is unplugged. But when plugged in, I notice that firewall blocks DNS
access for svchost.exe (4 times, total 8 seconds duration) and `go test net -short`
hangs(well it did one time), but after this 
running `go test net -short` doesn't hang anymore. It's almost as if it only happens
right after plugging in the internet cable and when firewall is denying DNS to
svchost... so if I plug the internet cable and wait like 10 seconds (until firewall is
done denying svchost DNS 4 times) then run `go test net -short` it will work and any
successive runs still work. But if I plug the cable and then run `got test net -short`
... well it still works so far :)) I guess maybe that was a coincidence that it hung
when it did
I really can't reproduce this hang... I just got another hang after unplugging and then
running `go test net`, so I really don't know

@alexbrainman
Copy link
Member

Comment 12:

I wouldn't worry trying to fight with firewalls or antiviruses. Just don't run net
tests. Just write whatever you want to write, and worry about real problems when they
happens.
Alex

@gopherbot
Copy link
Author

Comment 13 by atkaaz:

Ok. 
 Going back to the reported issue: the test fails(WSAENOPROTOOPT) because I have manually disabled multicast support in OS (IGMPLevel 0, instead of 2 or 1). So I'm not really sure what can be done with this in Go (maybe close the issue? if nothing else) Or maybe somehow make sure the error includes this fact: that either that error happened(and thus you have multicast support enabled in OS) OR that you may have manually disabled multicast support in OS.(wonder if there's some way to detect if multicast support is enabled or disabled, and have it reported as an error instead)

@alexbrainman
Copy link
Member

Comment 14:

I would say your setting change is non-standard, so test failure is expected. Closing
this issue, but feel free to comment. Maybe mikio will decide to do something.
Alex

Status changed to Retracted.

@rsc rsc added this to the Go1.2 milestone Apr 14, 2015
@rsc rsc removed the go1.2maybe label Apr 14, 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

4 participants