Skip to content

cmd/compile: incorrect boolean value passed to function #18725

Closed

Description

@toolateforteddy

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

go version go1.8rc2 darwin/amd64

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

GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"

What did you do?

https://play.golang.org/p/hebuAYQ6eo
Take the program above, that on go 1.7.4 prints out "The right thing.", and run that with a go compiler of version 1.8rc2. You now find that it prints out "The wrong thing." Additionally interesting, if you comment out line 15, the second call to "panicWhen", then the first call behaves correctly.

What did you expect to see?

I expect the program to panic with "The right thing."

What did you see instead?

The first call to panicWhen gets the argument cond as false, and panics with "The wrong thing."

Activity

  1. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    on Jan 20, 2017
  2. added this to the Go1.8 milestone on Jan 20, 2017
  3. robpike commented on Jan 20, 2017

    @robpike
    Contributor

    Confirmed. This is a bug that appeared in 1.8.

  4. bradfitz commented on Jan 20, 2017

    @bradfitz
    Contributor
  5. changed the title [-]Incorrect boolean value passed to function[/-] [+]cmd/compile: incorrect boolean value passed to function[/+] on Jan 20, 2017
  6. cherrymui commented on Jan 20, 2017

    @cherrymui
    Member

    The bug is in nilcheck phase, where there is a NilCheck Op in the same block as IsNonNil and happened to be stored before it (since values are not stored in order, until the scheduling phase). But logically NilCheck is after the IsNonNil.

  7. cherrymui commented on Jan 20, 2017

    @cherrymui
    Member

    I think we should explicitly check the memory to set/clear nonNilValues.

  8. dsnet commented on Jan 20, 2017

    @dsnet
    Member

    If it helps, git-bisect shows the offending commit as: 3134ab3, which is a trivial change of only a thousand or so lines ;)

  9. cherrymui commented on Jan 20, 2017

    @cherrymui
    Member

    @dsnet, yes, that is it. Before that commit, NilCheck always introduces a new block (BlockCheck) which enforces the value ordering. After that, it no longer introduces new block, so NilCheck could affect values in the same block but logically before it.

  10. tzneal commented on Jan 20, 2017

    @tzneal
    Member

    Not sure where gopherbot is, there's a CL at http://golang.org/cl/35495

  11. randall77 commented on Jan 20, 2017

    @randall77
    Contributor

    Also proposed CLs at https://golang.org/cl/35496 (Cherry's) and https://golang.org/cl/35485 (mine).

  12. gopherbot commented on Jan 24, 2017

    @gopherbot
    Contributor

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

  13. locked and limited conversation to collaborators on Jan 24, 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

    Labels

    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