From: Cherry Zhang Date: Thu, 15 Apr 2021 15:19:30 +0000 (-0400) Subject: reflect: preserve ctxt across moveMakeFuncArgPtrs X-Git-Tag: go1.17beta1~593 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=4fb74e055595a0009f11272432c2a5047a64507b;p=gostls13.git reflect: preserve ctxt across moveMakeFuncArgPtrs In makeFuncStub and methodValueCall, it stores ctxt (DX) as an argument of moveMakeFuncArgPtrs, and assumes it does not change by the call. This is not guaranteed, and it does happen if -clobberdead compiler flag is used. Store it somewhere else and reload after the call. Change-Id: I9307e3cf94db4b38305ab35494088386dfcbaae8 Reviewed-on: https://go-review.googlesource.com/c/go/+/310409 Trust: Cherry Zhang Run-TryBot: Cherry Zhang TryBot-Result: Go Bot Reviewed-by: Michael Knyszek Reviewed-by: Than McIntosh --- diff --git a/src/reflect/asm_amd64.s b/src/reflect/asm_amd64.s index 22d95f2a7e..facf07516d 100644 --- a/src/reflect/asm_amd64.s +++ b/src/reflect/asm_amd64.s @@ -33,9 +33,12 @@ TEXT ·makeFuncStub(SB),(NOSPLIT|WRAPPER),$312 // frame is specially handled in the runtime. See the comment above LOCAL_RETVALID. LEAQ LOCAL_REGARGS(SP), R12 CALL runtime·spillArgs(SB) + MOVQ DX, 24(SP) // outside of moveMakeFuncArgPtrs's arg area MOVQ DX, 0(SP) MOVQ R12, 8(SP) CALL ·moveMakeFuncArgPtrs(SB) + MOVQ 24(SP), DX + MOVQ DX, 0(SP) LEAQ argframe+0(FP), CX MOVQ CX, 8(SP) MOVB $0, LOCAL_RETVALID(SP) @@ -61,9 +64,12 @@ TEXT ·methodValueCall(SB),(NOSPLIT|WRAPPER),$312 // frame is specially handled in the runtime. See the comment above LOCAL_RETVALID. LEAQ LOCAL_REGARGS(SP), R12 CALL runtime·spillArgs(SB) + MOVQ DX, 24(SP) // outside of moveMakeFuncArgPtrs's arg area MOVQ DX, 0(SP) MOVQ R12, 8(SP) CALL ·moveMakeFuncArgPtrs(SB) + MOVQ 24(SP), DX + MOVQ DX, 0(SP) LEAQ argframe+0(FP), CX MOVQ CX, 8(SP) MOVB $0, LOCAL_RETVALID(SP)