-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
testing: calling TempDir() from a Benchmark causes it to fail #41062
Comments
Neat find! This also applies to calls to |
For sure! I submitted the PR on Gerrill as a demo of the issue and a possible fix. Unfortunately, I discovered it while writing benchmarks for my job that I definitely need to get back to. So I probably won't have time to go through the revision process for the PR -- but I suspect you all will find a more ideal solution :) Please let me know if you need any more from me. In the mean time, I'll just workaround with |
Thanks for at least getting us started with a report and a solid test case! |
Change https://golang.org/cl/251297 mentions this issue: |
Any chance this would be backported to Go 1.15? |
We usually only backport changes that are serious bugs that don't have a workaround, and this one has a pretty easy workaround. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
What did you see instead?
I dug into the benchmark, determined the first run succeeded, but on a short benchmark that is run again with N>1, the failure happens.
I dug into the benchmark.go source code and I believe the problem is that after every benchmark is run, common.runCleanup is called.
runCleanup
will delete the top level source folder under which TempDir() creates more temp directories. However, the top level source directory is only created once due to the sync.Once mutex.I went ahead and wrote a test and possible fix which I submitted to Gerril -- https://go-review.googlesource.com/c/go/+/250950
I have no idea if the fix is right (it does make the test pass) but the test should demonstrate the problem.
The text was updated successfully, but these errors were encountered: