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

runtime: SetFinalizer documentation ambiguous or confusing #24480

Closed
seebs opened this issue Mar 21, 2018 · 2 comments
Closed

runtime: SetFinalizer documentation ambiguous or confusing #24480

seebs opened this issue Mar 21, 2018 · 2 comments

Comments

@seebs
Copy link
Contributor

@seebs seebs commented Mar 21, 2018

What version of Go are you using (go version)?

1.10

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

N/A; this is a documentation bug.

What did you do?

Read the documentation.

What did you expect to see?

Something clearer.

What did you see instead?

The documentation for runtime.SetFinalizer says:

The finalizer for obj is scheduled to run at some arbitrary time after obj becomes unreachable.

The text as a whole strongly suggests that the meaning is "at some arbitrary time after the object pointed to by obj becomes unreachable".

Consider:

p := &something
{
q := p
runtime.SetFinalizer(q, ...)
}
// can the finalizer be invoked here, as q is now unreachable?

Consensus among some devs is that the answer is probably "no", but the actual words used appear to state that, since obj (q) is unreachable, the finalizer can run.

@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Mar 22, 2018

(CC: @aclements, @RLH for GC terminology)

@bcmills bcmills added this to the Go1.11 milestone Mar 22, 2018
@ALTree ALTree changed the title SetFinalizer documentation ambiguous or confusing runtime: SetFinalizer documentation ambiguous or confusing Mar 22, 2018
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Jul 7, 2018

Change https://golang.org/cl/122557 mentions this issue: runtime: clarify SetFinalizer docs

@gopherbot gopherbot closed this in fb59bcc Jul 9, 2018
@golang golang locked and limited conversation to collaborators Jul 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.