testaroli icon indicating copy to clipboard operation
testaroli copied to clipboard

Overrideing trampoline functions on ARM fails

Open qrdl opened this issue 9 months ago • 0 comments

When running test case

func TestOverrideInstanceMethodWithReference(t *testing.T) {
	s1 := square{side: 5}

	// use a reference to call the overridden trampoline function
	method := s1.Area

	Override(TestingContext(t), method, Always, func() float64 {
		return 10
	})()

	if method() != 10 {   // PANIC
		t.Errorf("Got unexpected result")
	}

	testError(t, nil, ExpectationsWereMet())
}

method() calls panics on ARM builds:

=== RUN   TestOverrideInstanceMethodWithReference
unexpected fault address 0x1083d9b90
fatal error: fault
[signal SIGBUS: bus error code=0x1 addr=0x1083d9b90 pc=0x1083d9b90]

goroutine 7 gp=0x14000003dc0 m=3 mp=0x14000015808 [running]:
runtime.throw({0x1043e29af?, 0x0?})
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:1067 +0x38 fp=0x1400012fdd0 sp=0x1400012fda0 pc=0x1041b7f08
runtime.sigpanic()
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/signal_unix.go:914 +0x10c fp=0x1400012fe00 sp=0x1400012fdd0 pc=0x1041b9b4c
github.com/qrdl/testaroli.TestOverrideInstanceMethodWithReference(0x1400010c9c0)
	/Users/runner/work/testaroli/testaroli/interfaces_test.go:57 +0xc0 fp=0x1400012feb0 sp=0x1400012fe10 pc=0x1043d22b0
testing.tRunner(0x1400010c9c0, 0x1044759c0)
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/testing/testing.go:1690 +0x1a8 fp=0x1400012ffa0 sp=0x1400012feb0 pc=0x104341a08
testing.(*T).Run.gowrap1()
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/testing/testing.go:1743 +0x38 fp=0x1400012ffd0 sp=0x1400012ffa0 pc=0x104343228
runtime.goexit({})
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/asm_arm64.s:1223 +0x4 fp=0x1400012ffd0 sp=0x1400012ffd0 pc=0x1041c00c4
created by testing.(*T).Run in goroutine 1
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/testing/testing.go:1743 +0x668

goroutine 1 gp=0x140000021c0 m=nil [chan receive, locked to thread]:
runtime.gopark(0x104475da8, 0x14000022760, 0xe, 0x7, 0x2)
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/proc.go:424 +0xe0 fp=0x14000133400 sp=0x140001333d0 pc=0x1041b8040
runtime.chanrecv(0x14000022700, 0x14000133506, 0x1)
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/chan.go:639 +0x298 fp=0x14000133480 sp=0x14000133400 pc=0x10414d4f8
runtime.chanrecv1(0x1045eb640?, 0x10442c020?)
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/chan.go:489 +0x14 fp=0x140001334b0 sp=0x14000133480 pc=0x10414d224
testing.(*T).Run(0x1400010c9c0, {0x1043eeaf7, 0x27}, 0x1044759c0)
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/testing/testing.go:1751 +0x688 fp=0x140001336d0 sp=0x140001334b0 pc=0x104343038
testing.runTests.func1(0x1400010c680)
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/testing/testing.go:2168 +0x98 fp=0x14000133770 sp=0x140001336d0 pc=0x1043466e8
testing.tRunner(0x1400010c680, 0x14000133948)
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/testing/testing.go:1690 +0x1a8 fp=0x14000133860 sp=0x14000133770 pc=0x104341a08
testing.runTests(0x1400000e060, {0x1045d31c0, 0x29, 0x29}, {0xc1ed780120580f50, 0x8bb2dfdc14, 0x1045eba00})
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/testing/testing.go:2166 +0x444 fp=0x14000133990 sp=0x14000133860 pc=0x104346534
testing.(*M).Run(0x1400007c0a0)
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/testing/testing.go:2034 +0xb08 fp=0x14000133ed0 sp=0x14000133990 pc=0x104344448
main.main()
	_testmain.go:135 +0x98 fp=0x14000133f60 sp=0x14000133ed0 pc=0x1043e0dd8
runtime.main()
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/proc.go:272 +0x224 fp=0x14000133fd0 sp=0x14000133f60 pc=0x104182db4
runtime.goexit({})
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/asm_arm64.s:1223 +0x4 fp=0x14000133fd0 sp=0x14000133fd0 pc=0x1041c00c4

goroutine 2 gp=0x14000002c40 m=nil [force gc (idle)]:
runtime.gopark(0x1044760d8, 0x1045eb3d0, 0x11, 0xa, 0x1)
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/proc.go:424 +0xe0 fp=0x14000046f70 sp=0x14000046f40 pc=0x1041b8040
runtime.goparkunlock(0x1045eb3d0?, 0x0?, 0x0?, 0x0?)
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/proc.go:430 +0x34 fp=0x14000046fa0 sp=0x14000046f70 pc=0x104183244
runtime.forcegchelper()
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/proc.go:337 +0xb4 fp=0x14000046fd0 sp=0x14000046fa0 pc=0x104183114
runtime.goexit({})
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/asm_arm64.s:1223 +0x4 fp=0x14000046fd0 sp=0x14000046fd0 pc=0x1041c00c4
created by runtime.init.7 in goroutine 1
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/proc.go:325 +0x24

goroutine 3 gp=0x14000003180 m=nil [GC sweep wait]:
runtime.gopark(0x1044760d8, 0x1045eb660, 0xc, 0x9, 0x1)
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/proc.go:424 +0xe0 fp=0x14000047740 sp=0x14000047710 pc=0x1041b8040
runtime.goparkunlock(0x1045eb660?, 0x0?, 0x0?, 0x0?)
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/proc.go:430 +0x34 fp=0x14000047770 sp=0x14000047740 pc=0x104183244
runtime.bgsweep(0x14000024080)
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/mgcsweep.go:277 +0x9c fp=0x140000477b0 sp=0x14000047770 pc=0x10416aadc
runtime.gcenable.gowrap1()
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/mgc.go:204 +0x28 fp=0x140000477d0 sp=0x140000477b0 pc=0x10415f338
runtime.goexit({})
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/asm_arm64.s:1223 +0x4 fp=0x140000477d0 sp=0x140000477d0 pc=0x1041c00c4
created by runtime.gcenable in goroutine 1
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/mgc.go:204 +0x6c

goroutine 4 gp=0x14000003340 m=nil [GC scavenge wait]:
runtime.gopark(0x1044760d8, 0x1045eba80, 0xd, 0xa, 0x2)
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/proc.go:424 +0xe0 fp=0x14000047f20 sp=0x14000047ef0 pc=0x1041b8040
runtime.goparkunlock(0x1045eba80?, 0x20?, 0xe8?, 0x1?)
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/proc.go:430 +0x34 fp=0x14000047f50 sp=0x14000047f20 pc=0x104183244
runtime.(*scavengerState).park(0x1045eba80)
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/mgcscavenge.go:425 +0x4c fp=0x14000047f80 sp=0x14000047f50 pc=0x10416814c
runtime.bgscavenge(0x14000024080)
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/mgcscavenge.go:653 +0x44 fp=0x14000047fb0 sp=0x14000047f80 pc=0x104168694
runtime.gcenable.gowrap2()
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/mgc.go:205 +0x28 fp=0x14000047fd0 sp=0x14000047fb0 pc=0x10415f2d8
runtime.goexit({})
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/asm_arm64.s:1223 +0x4 fp=0x14000047fd0 sp=0x14000047fd0 pc=0x1041c00c4
created by runtime.gcenable in goroutine 1
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/mgc.go:205 +0xac

goroutine 5 gp=0x14000003c00 m=nil [finalizer wait]:
runtime.gopark(0x104475e08, 0x104611c88, 0x10, 0xa, 0x1)
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/proc.go:424 +0xe0 fp=0x14000046590 sp=0x14000046560 pc=0x1041b8040
runtime.runfinq()
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/mfinal.go:193 +0xf0 fp=0x140000467d0 sp=0x14000046590 pc=0x10415e4c0
runtime.goexit({})
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/asm_arm64.s:1223 +0x4 fp=0x140000467d0 sp=0x140000467d0 pc=0x1041c00c4
created by runtime.createfing in goroutine 1
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/mfinal.go:163 +0x4c
FAIL	github.com/qrdl/testaroli	0.026s
FAIL

qrdl avatar Mar 15 '25 11:03 qrdl