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

Channel send blocks indefinitely on empty struct with type assertion #2232

Closed
gopherbot opened this issue Sep 5, 2011 · 3 comments
Closed

Comments

@gopherbot
Copy link
Contributor

by jnwhiteh:

What steps will reproduce the problem?
1. git clone git://gist.github.com/1195562.git gist-1195562 or retrieve and unzip the
attached file
2. cd gist-1195562
3. gotest

What is the expected output?

2011/09/05 19:11:19 Got an square message
2011/09/05 19:11:19 Got a cube message
2011/09/05 19:11:19 Got a close message
PASS

What do you see instead?

2011/09/05 19:10:39 Got an square message
2011/09/05 19:10:39 Got a cube message
2011/09/05 19:10:39 Got a close message
throw: all goroutines are asleep - deadlock!

goroutine 1 [chan receive]:
testing.RunTests(0x2000, 0xf0de8, 0x100000001, 0x219c)
    /Users/jnwhiteh/scm/golang.hg/src/pkg/testing/testing.go:201 +0x440
testing.Main(0x2000, 0xf0de8, 0x100000001, 0xfc528, 0x0, ...)
    /Users/jnwhiteh/scm/golang.hg/src/pkg/testing/testing.go:168 +0x54
main.main()
    /Users/jnwhiteh/Desktop/gist-1195562/_testmain.go:29 +0x6d

goroutine 2 [chan receive]:
foo.TestShutdown(0x421363a0, 0x0)
    /Users/jnwhiteh/Desktop/gist-1195562/foo_test.go:21 +0x193
testing.tRunner(0x421363a0, 0xf0de8, 0x0, 0x0)
    /Users/jnwhiteh/scm/golang.hg/src/pkg/testing/testing.go:156 +0x2b
created by testing.RunTests
    /Users/jnwhiteh/scm/golang.hg/src/pkg/testing/testing.go:200 +0x420

goroutine 3 [chan send]:
foo.(*Server).loop(0x42136360, 0x0)
    /Users/jnwhiteh/Desktop/gist-1195562/foo.go:41 +0x2e1
created by foo.NewServer
    /Users/jnwhiteh/Desktop/gist-1195562/foo.go:20 +0xb4
gotest: "./6.out" failed: exit status 2

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

6g

Which operating system are you using?

Mac OS X 10.7.1

Which revision are you using?  (hg identify)

02cfad1793be tip

Please provide any additional information below.

I tried to create a (more) minimal test case, but I was having trouble reproducing the
issue with smaller cases, so this is a very simple program that directly mirrors the
structure of a part of my code and demonstrates the issue.

The main problem is that the following code blocks indefinitely:

    res := (<-s.out).(m_res_close)

whereas this version works correctly

    <-s.out

as does this version (showing the types do in fact match):

    msg := <-s.out
        res := msg.(m_res_close)

Additionally it appears that if the struct (m_res_close) contains an item such as an
int, the problem goes away and the code that fails above will succeed.

Attachments:

  1. gist-1195562.zip (1663 bytes)
@gopherbot
Copy link
Contributor Author

Comment 1 by jnwhiteh:

I should say that I did recompile the source tree with escape analysis disabled (just in
case that was part of the issue) but it did not alter the results. Additionally, I
cannot reproduce this issue when using release.r59.

@rsc
Copy link
Contributor

rsc commented Sep 5, 2011

Comment 2:

Status changed to Started.

@rsc
Copy link
Contributor

rsc commented Sep 5, 2011

Comment 3:

This issue was closed by revision 919cb2e.

Status changed to Fixed.

@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

2 participants