<ol dir="auto">
<li>What version of Go are you using (<code class="notranslate">go version</code>)? go1.6</li>
<li>What operating system and processor architecture are you using (<code class="notranslate">go env</code>)? linux/amd64</li>
<li>What did you do? <a href="http://play.golang.org/p/1MigDGnopS" rel="nofollow">http://play.golang.org/p/1MigDGnopS</a> (unfortunately this cannot execute because of cgo)</li>
<li>What did you expect to see? One line printed to standard output containing text "test" (edit: as is output by this very similar, working example <a href="http://play.golang.org/p/eX1pSIjmo4" rel="nofollow">http://play.golang.org/p/eX1pSIjmo4</a>)</li>
<li>What did you see instead?</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="panic: runtime error: cgo argument has Go pointer to Go pointer

goroutine 1 [running]:
panic(0x474d20, 0xc82000a210)
    /usr/lib/go/src/runtime/panic.go:464 +0x3e6
main._cgoCheckPointer0(0x4697e0, 0xc820054094, 0x0, 0x0, 0x0, 0x0)
    github.com/bmatsuo/lmdb-go/tmp/_obj/_cgo_gotypes.go:42 +0x4d
main.main()
    /home/b/src/github.com/bmatsuo/lmdb-go/tmp/cgopanic.go:24 +0x153"><pre class="notranslate"><code class="notranslate">panic: runtime error: cgo argument has Go pointer to Go pointer

goroutine 1 [running]:
panic(0x474d20, 0xc82000a210)
    /usr/lib/go/src/runtime/panic.go:464 +0x3e6
main._cgoCheckPointer0(0x4697e0, 0xc820054094, 0x0, 0x0, 0x0, 0x0)
    github.com/bmatsuo/lmdb-go/tmp/_obj/_cgo_gotypes.go:42 +0x4d
main.main()
    /home/b/src/github.com/bmatsuo/lmdb-go/tmp/cgopanic.go:24 +0x153
</code></pre></div>
<p dir="auto">I'm creating this issue to track a problem I brought up in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="131077752" data-permission-text="Title is private" data-url="https://github.com/golang/go/issues/14210" data-hovercard-type="issue" data-hovercard-url="/golang/go/issues/14210/hovercard?comment_id=185814124&amp;comment_type=issue_comment" href="https://github.com/golang/go/issues/14210#issuecomment-185814124">#14210 (comment)</a> but for which the cause/fix was different. I took some time before filing the issue to collect more information about the problem and the fix for my own understanding. My apologies for the delay. But it didn't look like a duplicate has been filed since.</p>
<p dir="auto">I was also told to replace my code that looked like the above example with code which takes the address of a <code class="notranslate">[]byte</code> at the actual cgo call site to help the tool figure out which memory region I was referring to. I have done so, and it works, but I have found the result to be significantly slower that before I made this change (both benchmarks takes from a stock go1.6 build -- no flags).</p>
<p dir="auto">The changes I made to work around the above panic in my actual project can be found here: <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/bmatsuo/lmdb-go/commit/40ebaca9ecf9cd77b0b70fc5eb6a89c47a839187/hovercard" href="https://github.com/bmatsuo/lmdb-go/commit/40ebaca9ecf9cd77b0b70fc5eb6a89c47a839187">bmatsuo/lmdb-go@<tt>40ebaca</tt></a></p>
<p dir="auto">And the performance comparison against master can be seen in my pull request: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="139190696" data-permission-text="Title is private" data-url="https://github.com/bmatsuo/lmdb-go/issues/57" data-hovercard-type="pull_request" data-hovercard-url="/bmatsuo/lmdb-go/pull/57/hovercard?comment_id=193624370&amp;comment_type=issue_comment" href="https://github.com/bmatsuo/lmdb-go/pull/57#issuecomment-193624370">bmatsuo/lmdb-go#57 (comment)</a></p>
<p dir="auto">My benchmarks, unfortunately, have more noise than I would like but there is a definite pattern that shows this change having a real impact on call times (especially for some functions which should execute be extremely quickly). The relevant benchmarks show a 7-43% performance penalty from this change (100ns+ per affected C call).</p>
<pre class="notranslate">---------- Forwarded message ----------
From: james4k &lt;sslice@gmail.com&gt;
Date: Mon, Aug 12, 2013 at 5:30 PM
Subject: [golang-dev] cgo and guessKind() on darwin (10.8)
To: golang-dev@googlegroups.com


Hello,

On tip I am receiving a cgo error on the package github.com/go-gl/gl, while it works
fine on 1.1; the output is "gcc produced no output". This error comes from the
guessKind() method in src/cmd/cgo/gcc.go and appears to have started when clang was made
the default CC for darwin. Testing this with CC=gcc seems to confirm this (builds
successfully). I have not tested this with any other versions of clang or on linux, but
it looks like guessKind() is a very GCC specific routine that will need to be adapted to
support other compilers like clang, but I have limited knowledge on this.

Not sure whether or not to submit an actual issue as non-gcc support seemed to be a work
in progress, but posted here for your awareness.

$ clang -v
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.4.0
Thread model: posix</pre>