You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cmd/compile: incorrect boolean value passed to function #18725
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."
Reacted by Felix Tripier, Cholerae Hu, Brad Fitzpatrick, Darren Hoo, Josh Bleecher Snyder, Emmanuel T Odeke and Renann Prado
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.
@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.
Activity
robpike commentedon Jan 20, 2017
Confirmed. This is a bug that appeared in 1.8.
bradfitz commentedon Jan 20, 2017
/cc @randall77 @mdempsky @griesemer
[-]Incorrect boolean value passed to function[/-][+]cmd/compile: incorrect boolean value passed to function[/+]cherrymui commentedon Jan 20, 2017
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.
cherrymui commentedon Jan 20, 2017
I think we should explicitly check the memory to set/clear
nonNilValues.dsnet commentedon Jan 20, 2017
If it helps, git-bisect shows the offending commit as: 3134ab3, which is a trivial change of only a thousand or so lines ;)
cherrymui commentedon Jan 20, 2017
@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.
tzneal commentedon Jan 20, 2017
Not sure where gopherbot is, there's a CL at http://golang.org/cl/35495
randall77 commentedon Jan 20, 2017
Also proposed CLs at https://golang.org/cl/35496 (Cherry's) and https://golang.org/cl/35485 (mine).
gopherbot commentedon Jan 24, 2017
CL https://golang.org/cl/35496 mentions this issue.
cmd/compile: re-enable nilcheck removal in same block