Skip to content

cmd/compile: wrong liveness map #18860

Closed
Closed

Description

@randall77
func f(p, q *int) (r *int) {
	r = p
	defer func() {
		recover()
	}()
	g()
	r = q
	return
}
func g()

At the call to g, r should be marked as live. It isn't.

> go tool compile -live ~/go/tmp3.go
tmp3.go:3: live at entry to f: p q
tmp3.go:7: live at call to deferproc: q r
tmp3.go:8: live at call to g: q                   <- r is live here
tmp3.go:10: live at call to deferreturn: r
tmp3.go:7: live at call to deferreturn: r

Any defer makes all of the output args live at any (possibly panicing) call.
Found using the dead-slot clobberer, https://go-review.googlesource.com/c/23924/
Seems to be around for a while, at least 1.6.
I'm not sure why the dead-slot clobberer didn't find this before.

(Note to self: original detection from encoding/gob/encoder_test.go:encodeAndRecover.)

Activity

  1. added this to the Go1.8Maybe milestone on Jan 30, 2017
  2. self-assigned this
    on Jan 30, 2017
  3. randall77 commented on Jan 30, 2017

    @randall77
    ContributorAuthor
  4. gopherbot commented on Jan 30, 2017

    @gopherbot
    Contributor

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

  5. modified the milestones: Go1.9, Go1.8Maybe on Jan 31, 2017
  6. gopherbot commented on Feb 3, 2017

    @gopherbot
    Contributor

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

  7. gopherbot commented on Mar 13, 2017

    @gopherbot
    Contributor

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

  8. locked and limited conversation to collaborators on Mar 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions