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

sync: add comment to docs detailing behavior when once.Do function panics #8118

Closed
gopherbot opened this issue May 28, 2014 · 5 comments
Closed

Comments

@gopherbot
Copy link

by gconnell@google.com:

Right now, sync.Once has this behavior with the attached code:

PANIC!!!
PANIC!!!
PANIC!!!

IE: if a sync.Once function panics, the Once is not marked as "done", and on
recovery the Once function is called more than once.

I found this pretty unexpected, and I'm wondering if a note about this behavior could be
added to the docs of sync.Once.

go version go1.2 linux/amd64

Attachments:

  1. test.go (239 bytes)
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-main, release-go1.4, documentation.

@robpike
Copy link
Contributor

robpike commented May 29, 2014

Comment 2:

Owner changed to @robpike.

@robpike
Copy link
Contributor

robpike commented May 29, 2014

Comment 3:

Status changed to Accepted.

@gopherbot
Copy link
Author

Comment 4:

CL https://golang.org/cl/137350043 mentions this issue.

@robpike
Copy link
Contributor

robpike commented Sep 16, 2014

Comment 5:

This issue was closed by revision b22dc63.

Status changed to Fixed.

@rsc rsc added this to the Go1.4 milestone Apr 14, 2015
@rsc rsc removed the release-go1.4 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jun 25, 2018
This is a corner case, and one that was even tested, but this
CL changes the behavior to say that f is "complete" even if it panics.
But don't think of it that way, think of it as sync.Once runs
the function only the first time it is called, rather than
repeatedly until a run of the function completes.

Fixes golang#8118.

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/137350043
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jul 9, 2018
This is a corner case, and one that was even tested, but this
CL changes the behavior to say that f is "complete" even if it panics.
But don't think of it that way, think of it as sync.Once runs
the function only the first time it is called, rather than
repeatedly until a run of the function completes.

Fixes golang#8118.

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/137350043
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jul 30, 2018
This is a corner case, and one that was even tested, but this
CL changes the behavior to say that f is "complete" even if it panics.
But don't think of it that way, think of it as sync.Once runs
the function only the first time it is called, rather than
repeatedly until a run of the function completes.

Fixes golang#8118.

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/137350043
@rsc rsc unassigned robpike Jun 23, 2022
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

4 participants