Giter Club home page Giter Club logo

Comments (6)

xhd2015 avatar xhd2015 commented on May 23, 2024 1

same problem vv2.11.0, processor: m3pro

+1

@wustrong @shubham-dogra-pingsafe 已经有项目用xgo验证可以兼容M2,M3,参考: kilianc/base-golang#3

xgo使用:https://github.com/xhd2015/xgo .

from gomonkey.

agiledragon avatar agiledragon commented on May 23, 2024

Can you post the complete program?

from gomonkey.

leojin avatar leojin commented on May 23, 2024
  1. Environment:
  1. Function Codes
package main

func main() {
	_, _, _ = Execute()
}

func Execute() (int, int, int) {
	s := S{}
	return F1(), F2(), s.F3()
}

func F1() int {
	return 1
}

func F2() int {
	return 2
}

type S struct {
}

func (*S) F3() int {
	return 3
}
  1. Works with one patch
package main_test

import (
	"github.com/agiledragon/gomonkey/v2"
	"github.com/go-playground/assert/v2"
	"gomonkey_arm64"
	"testing"
)

func TestExecute(t *testing.T) {
	rst1Expect := 11
	gomonkey.
		ApplyFunc(main.F1, func() int {
			return rst1Expect
		})
	rst1, _, _ := main.Execute()
	assert.Equal(t, rst1Expect, rst1)
}
  1. Fail with multi ApplyFunc/Method

It can work with the env GOARCH=amd64

package main_test

import (
	"github.com/agiledragon/gomonkey/v2"
	"github.com/go-playground/assert/v2"
	"gomonkey_arm64"
	"reflect"
	"testing"
)

func TestExecute(t *testing.T) {
	s := main.S{}
	rst1Expect := 11
	rst2Expect := 12
	rst3Expect := 13
	gomonkey.
		ApplyFunc(main.F1, func() int {
			return rst1Expect
		}).
		ApplyFunc(main.F2, func() int {
			return rst2Expect
		}).
		ApplyMethod(reflect.TypeOf(&s), "F3", func(_ *main.S) int {
			return rst3Expect
		})
	rst1, rst2, rst3 := main.Execute()
	assert.Equal(t, rst1Expect, rst1)
	assert.Equal(t, rst2Expect, rst2)
	assert.Equal(t, rst3Expect, rst3)
}
/Users/jinzheng/go/go1.20.12/bin/go tool test2json -t /Users/jinzheng/Library/Caches/JetBrains/GoLand2023.3/tmp/GoLand/___1TestExecute_in_gomonkey_arm64.test -test.v -test.paniconexit0 -test.run ^\QTestExecute\E$
=== RUN   TestExecute
unexpected fault address 0x10052fa08
fatal error: fault
[signal SIGBUS: bus error code=0x1 addr=0x10052fa08 pc=0x10052fa08]

goroutine 6 [running]:
runtime.throw({0x100531d07?, 0x10052dde8?})
	/Users/jinzheng/go/go1.20.12/src/runtime/panic.go:1047 +0x40 fp=0x14000070c50 sp=0x14000070c20 pc=0x1003f4100
runtime.sigpanic()
	/Users/jinzheng/go/go1.20.12/src/runtime/signal_unix.go:838 +0x10c fp=0x14000070c80 sp=0x14000070c50 pc=0x10040af1c
github.com/agiledragon/gomonkey/v2.write(0x10052da50, 0x1400001a120, 0x18, 0x10052c000, 0x4000, 0x5)
	/Users/jinzheng/go/pkg/mod/github.com/agiledragon/gomonkey/[email protected]/write_darwin_arm64.s:36 +0x1028 fp=0x14000070cc0 sp=0x14000070c90 pc=0x10052fa08
github.com/agiledragon/gomonkey/v2.modifyBinary(0x18?, {0x1400001a120, 0x18, 0x18})
	/Users/jinzheng/go/pkg/mod/github.com/agiledragon/gomonkey/[email protected]/modify_binary_darwin.go:16 +0x78 fp=0x14000070d30 sp=0x14000070cc0 pc=0x10052dee8
github.com/agiledragon/gomonkey/v2.replace(0x100567d40?, 0x14000016340?)
	/Users/jinzheng/go/pkg/mod/github.com/agiledragon/gomonkey/[email protected]/patch.go:269 +0x74 fp=0x14000070da0 sp=0x14000070d30 pc=0x10052e874
github.com/agiledragon/gomonkey/v2.(*Patches).ApplyCore(0x1400000c0d8, {0x100567d40?, 0x1005a2ac0?, 0x140000745d0?}, {0x100567d40, 0x14000016340, 0x13})
	/Users/jinzheng/go/pkg/mod/github.com/agiledragon/gomonkey/[email protected]/patch.go:213 +0x74 fp=0x14000070e20 sp=0x14000070da0 pc=0x10052e314
github.com/agiledragon/gomonkey/v2.(*Patches).ApplyFunc(0x14000070ec8?, {0x100567d40?, 0x1005a2ac0?}, {0x100567d40, 0x14000016340})
	/Users/jinzheng/go/pkg/mod/github.com/agiledragon/gomonkey/[email protected]/patch.go:83 +0x70 fp=0x14000070e90 sp=0x14000070e20 pc=0x10052e110
github.com/agiledragon/gomonkey/v2.ApplyFunc({0x100567d40, 0x1005a2ac0}, {0x100567d40, 0x14000016340})
	/Users/jinzheng/go/pkg/mod/github.com/agiledragon/gomonkey/[email protected]/patch.go:25 +0x40 fp=0x14000070ed0 sp=0x14000070e90 pc=0x10052dfb0
gomonkey_arm64_test.TestExecute(0x0?)
	/Users/jinzheng/Projects/Personal/gomonkey_test/main_test.go:17 +0x5c fp=0x14000070f60 sp=0x14000070ed0 pc=0x1005310ac
testing.tRunner(0x14000003a00, 0x1005a2ad0)
	/Users/jinzheng/go/go1.20.12/src/testing/testing.go:1576 +0x114 fp=0x14000070fb0 sp=0x14000070f60 pc=0x1004b4554
testing.(*T).Run.func1()
	/Users/jinzheng/go/go1.20.12/src/testing/testing.go:1629 +0x2c fp=0x14000070fd0 sp=0x14000070fb0 pc=0x1004b525c
runtime.goexit()
	/Users/jinzheng/go/go1.20.12/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000070fd0 sp=0x14000070fd0 pc=0x100427b04
created by testing.(*T).Run
	/Users/jinzheng/go/go1.20.12/src/testing/testing.go:1629 +0x340

goroutine 1 [chan receive]:
runtime.gopark(0x1005a2d30, 0x1400005e138, 0xe, 0x17, 0x2)
	/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:381 +0xd8 fp=0x14000105aa0 sp=0x14000105a70 pc=0x1003f6938
runtime.chanrecv(0x1400005e0e0, 0x14000105baf, 0x1)
	/Users/jinzheng/go/go1.20.12/src/runtime/chan.go:583 +0x29c fp=0x14000105b30 sp=0x14000105aa0 pc=0x1003c208c
runtime.chanrecv1(0x10059f5c0?, 0x100569480?)
	/Users/jinzheng/go/go1.20.12/src/runtime/chan.go:442 +0x14 fp=0x14000105b60 sp=0x14000105b30 pc=0x1003c1db4
testing.(*T).Run(0x14000003860, {0x100533366, 0xb}, 0x1005a2ad0)
	/Users/jinzheng/go/go1.20.12/src/testing/testing.go:1630 +0x354 fp=0x14000105c20 sp=0x14000105b60 pc=0x1004b5124
testing.runTests.func1(0x14000105c01?)
	/Users/jinzheng/go/go1.20.12/src/testing/testing.go:2036 +0x48 fp=0x14000105c70 sp=0x14000105c20 pc=0x1004b6e18
testing.tRunner(0x14000003860, 0x14000105d68)
	/Users/jinzheng/go/go1.20.12/src/testing/testing.go:1576 +0x114 fp=0x14000105cc0 sp=0x14000105c70 pc=0x1004b4554
testing.runTests(0x1400010e0a0?, {0x1006b6720, 0x1, 0x1}, {0x100534642?, 0xf?, 0x0?})
	/Users/jinzheng/go/go1.20.12/src/testing/testing.go:2034 +0x334 fp=0x14000105d90 sp=0x14000105cc0 pc=0x1004b6d24
testing.(*M).Run(0x1400010e0a0)
	/Users/jinzheng/go/go1.20.12/src/testing/testing.go:1906 +0x458 fp=0x14000105ef0 sp=0x14000105d90 pc=0x1004b5b48
main.main()
	_testmain.go:49 +0x80 fp=0x14000105f70 sp=0x14000105ef0 pc=0x100531380
runtime.main()
	/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:250 +0x21c fp=0x14000105fd0 sp=0x14000105f70 pc=0x1003f64fc
runtime.goexit()
	/Users/jinzheng/go/go1.20.12/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000105fd0 sp=0x14000105fd0 pc=0x100427b04

goroutine 2 [force gc (idle)]:
runtime.gopark(0x1005a2f28, 0x1006bf100, 0x11, 0x14, 0x1)
	/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:381 +0xd8 fp=0x14000046f70 sp=0x14000046f40 pc=0x1003f6938
runtime.goparkunlock(0x0?, 0x0?, 0x0?, 0x0?)
	/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:387 +0x34 fp=0x14000046fa0 sp=0x14000046f70 pc=0x1003f69c4
runtime.forcegchelper()
	/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:305 +0xb4 fp=0x14000046fd0 sp=0x14000046fa0 pc=0x1003f6754
runtime.goexit()
	/Users/jinzheng/go/go1.20.12/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000046fd0 sp=0x14000046fd0 pc=0x100427b04
created by runtime.init.6
	/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:293 +0x24

goroutine 3 [GC sweep wait]:
runtime.gopark(0x1005a2f28, 0x1006bf520, 0xc, 0x14, 0x1)
	/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:381 +0xd8 fp=0x14000047740 sp=0x14000047710 pc=0x1003f6938
runtime.goparkunlock(0x0?, 0x0?, 0x0?, 0x0?)
	/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:387 +0x34 fp=0x14000047770 sp=0x14000047740 pc=0x1003f69c4
runtime.bgsweep(0x0?)
	/Users/jinzheng/go/go1.20.12/src/runtime/mgcsweep.go:278 +0xa0 fp=0x140000477b0 sp=0x14000047770 pc=0x1003e05c0
runtime.gcenable.func1()
	/Users/jinzheng/go/go1.20.12/src/runtime/mgc.go:178 +0x28 fp=0x140000477d0 sp=0x140000477b0 pc=0x1003d56b8
runtime.goexit()
	/Users/jinzheng/go/go1.20.12/src/runtime/asm_arm64.s:1172 +0x4 fp=0x140000477d0 sp=0x140000477d0 pc=0x100427b04
created by runtime.gcenable
	/Users/jinzheng/go/go1.20.12/src/runtime/mgc.go:178 +0x74

goroutine 4 [GC scavenge wait]:
runtime.gopark(0x1005a2f28, 0x1006bf6c0, 0xd, 0x14, 0x2)
	/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:381 +0xd8 fp=0x14000047f20 sp=0x14000047ef0 pc=0x1003f6938
runtime.goparkunlock(0x1400005e000?, 0x78?, 0xcf?, 0x1?)
	/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:387 +0x34 fp=0x14000047f50 sp=0x14000047f20 pc=0x1003f69c4
runtime.(*scavengerState).park(0x1006bf6c0)
	/Users/jinzheng/go/go1.20.12/src/runtime/mgcscavenge.go:400 +0x4c fp=0x14000047f80 sp=0x14000047f50 pc=0x1003de2ac
runtime.bgscavenge(0x0?)
	/Users/jinzheng/go/go1.20.12/src/runtime/mgcscavenge.go:628 +0x44 fp=0x14000047fb0 sp=0x14000047f80 pc=0x1003de7f4
runtime.gcenable.func2()
	/Users/jinzheng/go/go1.20.12/src/runtime/mgc.go:179 +0x28 fp=0x14000047fd0 sp=0x14000047fb0 pc=0x1003d5658
runtime.goexit()
	/Users/jinzheng/go/go1.20.12/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000047fd0 sp=0x14000047fd0 pc=0x100427b04
created by runtime.gcenable
	/Users/jinzheng/go/go1.20.12/src/runtime/mgc.go:179 +0xb8

goroutine 5 [finalizer wait]:
runtime.gopark(0x1005a2d98, 0x1006f3498, 0x10, 0x14, 0x1)
	/Users/jinzheng/go/go1.20.12/src/runtime/proc.go:381 +0xd8 fp=0x14000046580 sp=0x14000046550 pc=0x1003f6938
runtime.runfinq()
	/Users/jinzheng/go/go1.20.12/src/runtime/mfinal.go:193 +0xf4 fp=0x140000467d0 sp=0x14000046580 pc=0x1003d4874
runtime.goexit()
	/Users/jinzheng/go/go1.20.12/src/runtime/asm_arm64.s:1172 +0x4 fp=0x140000467d0 sp=0x140000467d0 pc=0x100427b04
created by runtime.createfing
	/Users/jinzheng/go/go1.20.12/src/runtime/mfinal.go:163 +0x4c

from gomonkey.

mwindson avatar mwindson commented on May 23, 2024

same problem

from gomonkey.

shubham-dogra-pingsafe avatar shubham-dogra-pingsafe commented on May 23, 2024

same problem vv2.11.0, processor: m3pro

from gomonkey.

wustrong avatar wustrong commented on May 23, 2024

same problem vv2.11.0, processor: m3pro

+1

from gomonkey.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.