Skip to content

runtime: SetFinalizer documentation ambiguous or confusing #24480

@seebs

Description

@seebs

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions