cmd/gc: never pass ptr to uninit temp to runtime
chanrecv now expects a pointer to the data to be filled in. mapiterinit expects a pointer to the hash iterator to be filled in. In both cases, the temporary being pointed at changes from dead to alive during the call. In order to make sure it is preserved if a garbage collection happens after that transition but before the call returns, the temp must be marked as live during the entire call. But if it is live during the entire call, it needs to be safe for the garbage collector to scan at the beginning of the call, before the new data has been filled in. Therefore, it must be zeroed by the caller, before the call. Do that. My previous attempt waited to mark it live until after the call returned, but that's unsafe (see first paragraph); undo that change in plive.c. This makes powser2 pass again reliably. I looked at every call to temp in the compiler. The vast majority are followed immediately by an initialization of temp, so those are fine. The only ones that needed changing were the ones where the next operation is to pass the address of the temp to a function call, and there aren't too many. Maps are exempted from this because mapaccess returns a pointer to the data and lets the caller make the copy. Fixes many builds. TBR=khr CC=golang-codereviews https://golang.org/cl/80700046
Showing
Please
register
or
sign in
to comment