<p dir="auto">For this function</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="package main

func f(fn func() error) error {
        return fn()
}

func main() {
        called := false
        f(func() error {
                called = true
                return nil
        })

}"><pre class="notranslate"><code class="notranslate">package main

func f(fn func() error) error {
        return fn()
}

func main() {
        called := false
        f(func() error {
                called = true
                return nil
        })

}
</code></pre></div>
<p dir="auto">gc considers <code class="notranslate">called</code> to be both set and used although nowhere in the scope is the value of <code class="notranslate">called</code> ever consulted.</p>
<p dir="auto">gccgo-5.0 on the other hand considers this code to be faulty</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="% env LD_LIBRARY_PATH=/opt/gccgo/lib64 PATH=$PATH:/opt/gccgo/bin go build -compiler=gccgo /tmp/x.go
# command-line-arguments
/tmp/x.go:8:2: error: ‘called’ declared and not used
  called := false
  ^"><pre class="notranslate"><code class="notranslate">% env LD_LIBRARY_PATH=/opt/gccgo/lib64 PATH=$PATH:/opt/gccgo/bin go build -compiler=gccgo /tmp/x.go
# command-line-arguments
/tmp/x.go:8:2: error: ‘called’ declared and not used
  called := false
  ^
</code></pre></div>
<p dir="auto">gccgo version</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="% env LD_LIBRARY_PATH=/opt/gccgo/lib64 PATH=$PATH:/opt/gccgo/bin gccgo -v
Using built-in specs.
COLLECT_GCC=gccgo
COLLECT_LTO_WRAPPER=/opt/gccgo/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/trunk/configure --prefix=/opt/gccgo --enable-languages=c,c++,go --disable-bootstrap
Thread model: posix
gcc version 5.0.0 20150324 (experimental) (GCC) "><pre class="notranslate"><code class="notranslate">% env LD_LIBRARY_PATH=/opt/gccgo/lib64 PATH=$PATH:/opt/gccgo/bin gccgo -v
Using built-in specs.
COLLECT_GCC=gccgo
COLLECT_LTO_WRAPPER=/opt/gccgo/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/trunk/configure --prefix=/opt/gccgo --enable-languages=c,c++,go --disable-bootstrap
Thread model: posix
gcc version 5.0.0 20150324 (experimental) (GCC) 
</code></pre></div>
<p dir="auto">by <strong><a href="mailto:scott+ctt@pakin.org">scott+ctt@pakin.org</a></strong>:</p>
<pre class="notranslate">&gt; What steps will reproduce the problem?

Build and run the attached Go program with GOMAXPROCS=2 or greater.  I 
used 6g/6l and ran on a dual-socket, quad-core, dual-thread Nehalem EP 
system.

&gt; What is the expected output? What do you see instead?

Expected: No output.

See instead: No output with GOMAXPROCS=1 or undefined.  No output if 
maxGoroutines is reduced from 10000 to 1000.  With GOMAXPROCS=2 or 
greater, I get the following:

free 0x7f1ec5b52000: not an allocated block
throw: free mlookup

panic PC=0x7f1ec57cf200
throw: malloc/free - deadlock
double panic

&gt; What is your $GOOS?  $GOARCH?

GOOS=linux
GOARCH=amd64

&gt; Which revision are you using?  (hg identify)

53fec18b83e2+ release/release.2010-02-17

&gt; Please provide any additional information below.

My larger code (of which the attached is merely a small reproducer) worked 
with the previous version of Go.</pre>
<p dir="auto">Attachments:</p>
<ol dir="auto">
<li><a href="https://storage.googleapis.com/go-attachment/619/0/broken.go" rel="nofollow">broken.go</a> (617 bytes)</li>
</ol>