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

Comments

Projects
None yet
4 participants
@seebs
Copy link
Contributor

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

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.