<pre class="notranslate">What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.

Compile &amp; run the code in:
  <a href="https://gist.github.com/ernestokarim/5033404">https://gist.github.com/ernestokarim/5033404</a>

It cannot be reproduced in the playground because it needs sqlite3.


What is the expected output?

Run without bugs.


What do you see instead?

Using any revision after this one:
  <a href="https://code.google.com/p/go/source/detail?r=ddb9e6365e57" rel="nofollow">https://code.google.com/p/go/source/detail?r=ddb9e6365e57</a>

it starts to consume file descriptors without end, you can check it:
  while [ 1 ] ; do ls /proc/6559/fd | wc -l ; sleep 1; done

even if I'm closing the prepared statements correctly. In the iteration 1021 it fails
with "unable to open database file".


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

8g.


Which operating system are you using?

Fedora 17, 32 bits. SQLite3, the latest version from the website.


Which version are you using?  (run 'go version')

go version devel +c0258d9a3589 Wed Feb 27 15:22:14 2013 -0800 linux/386


Please provide any additional information below.

<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="11381442" data-permission-text="Title is private" data-url="https://github.com/mattn/go-sqlite3/issues/41" data-hovercard-type="issue" data-hovercard-url="/mattn/go-sqlite3/issues/41/hovercard" href="https://github.com/mattn/go-sqlite3/issues/41">mattn/go-sqlite3#41</a></pre>
<pre class="notranslate">What steps will reproduce the problem?
1. compile attached program and run it

What is the expected output?
 the last value consumed by any of the multiple readers should be '9'

What do you see instead?
 the last value generated before the channel was closed is 9, but more often than not the last value consumed by any of the chan's readers is 8.

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

Which operating system are you using?
OSX

Which revision are you using?  (hg identify)
684ebd420f34+ tip

Please provide any additional information below.
The "9" does appear to be consumed occasionally:

$ while true; do ./6.out | egrep 'consumed: [89]'; done  | egrep -n 'consumed: 9'
180:consumed: 9
356:consumed: 9
569:consumed: 9
984:consumed: 9
989:consumed: 9
2166:consumed: 9
2235:consumed: 9
2295:consumed: 9
2350:consumed: 9
2929:consumed: 9
3039:consumed: 9</pre>
<p dir="auto">Attachments:</p>
<ol dir="auto">
<li><a href="https://storage.googleapis.com/go-attachment/1183/0/t.go" rel="nofollow">t.go</a> (405 bytes)</li>
</ol>