knqyf263 / go-plugin

Go Plugin System over WebAssembly
MIT License
586 stars 30 forks source link

unexpected fault address #63

Open amlwwalker opened 6 months ago

amlwwalker commented 6 months ago

I am sending data from the host to the plugin and i'm getting a huge crash every so often - after about 4-5 'sends' of data but can be 1 or 2 sometimes.

Anything glaringly obvious?

I have

  rpc PluginEvent(DataMessage) returns (google.protobuf.Empty) {}

in my service (.proto) and I have a function that is creating a listener for each of my plugins, so that they will fire on an event meant for them.

    for _, v := range a.pluginManager.Plugins {
        eventName := fmt.Sprintf("plugin_frontend_event_%s", v.Info.PluginId)
        runtime.EventsOn(ctx, eventName, func(optionalData ...interface{}) {
            ///codes,,,
            byt, err := json.Marshal(optionalData)
            if err != nil {
                fmt.Println("error marhsalling data ", err)
                return
            }
            var receivedDataMessages []interop.DataMessage
            if err := json.Unmarshal(byt, &receivedDataMessages); err == nil {
                fmt.Printf("optional data from frontend %d - %+v", len(receivedDataMessages), receivedDataMessages)
            } else {
                fmt.Println("error unmarshal ", err)
            }
            _, err = v.PluginEvent(ctx, &receivedDataMessages[0])

Where i call PluginEvent is where the crash ultimately happens. I am not sure if its possible to get debugging logs from a plugin at this point to see if anything happened in there: (thx)

unexpected fault address 0xfdd8
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x2 addr=0xfdd8 pc=0xfdd8]

goroutine 212 gp=0x140005d0a80 m=14 mp=0x14000680008 [running]:
runtime.throw({0x1050f05df?, 0x140001d05b0?})
        /usr/local/go/src/runtime/panic.go:1023 +0x40 fp=0x140002cf3d0 sp=0x140002cf3a0 pc=0x10434b4a0
runtime.sigpanic()
        /usr/local/go/src/runtime/signal_unix.go:895 +0x198 fp=0x140002cf400 sp=0x140002cf3d0 pc=0x104362d08
github.com/tetratelabs/wazero/internal/engine/compiler.(*callEngine).execWasmFunction(0x14000268c60, {0x10559ff90, 0x1400031b320}, 0x140001d0500)
        /Users/user/go/pkg/mod/github.com/tetratelabs/wazero@v1.6.0/internal/engine/compiler/engine.go:1043 +0x78 fp=0x140002cf580 sp=0x140002cf410 pc=0x104b321f8
github.com/tetratelabs/wazero/internal/engine/compiler.(*callEngine).call(0x14000268c60, {0x10559ff90, 0x1400031b320}, {0x14000129540, 0x2, 0x2}, {0x0, 0x0, 0x0})
        /Users/user/go/pkg/mod/github.com/tetratelabs/wazero@v1.6.0/internal/engine/compiler/engine.go:784 +0x2f0 fp=0x140002cf710 sp=0x140002cf580 pc=0x104b30d60
github.com/tetratelabs/wazero/internal/engine/compiler.(*callEngine).Call(0x14000268c60, {0x10559ff90, 0x1400031b320}, {0x14000129540, 0x2, 0x2})
        /Users/user/go/pkg/mod/github.com/tetratelabs/wazero@v1.6.0/internal/engine/compiler/engine.go:736 +0x1c8 fp=0x140002cf850 sp=0x140002cf710 pc=0x104b307b8
github.com/user/gui/pkg/plugins/interop.(*pluginServicePlugin).PluginEvent(0x140001bc280, {0x10559ff90, 0x1400031b320}, 0x140007e2480)
        /Users/user/go/src/github.com/user/gui/pkg/plugins/interop/interop_host.pb.go:546 +0x5e4 fp=0x140002cfce0 sp=0x140002cf850 pc=0x104c16564
main.(*Model).startup.func1({0x14000a1a370, 0x1, 0x1})
        /Users/user/go/src/github.com/user/gui/model.go:79 +0x61c fp=0x140002cff80 sp=0x140002cfce0 pc=0x1050dc74c
github.com/wailsapp/wails/v2/internal/frontend/runtime.(*Events).notifyBackend.gowrap2()
        /Users/user/go/pkg/mod/github.com/wailsapp/wails/v2@v2.8.2/internal/frontend/runtime/events.go:137 +0x4c fp=0x140002cffd0 sp=0x140002cff80 pc=0x1048da4bc
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x140002cffd0 sp=0x140002cffd0 pc=0x104380484
created by github.com/wailsapp/wails/v2/internal/frontend/runtime.(*Events).notifyBackend in goroutine 107
        /Users/user/go/pkg/mod/github.com/wailsapp/wails/v2@v2.8.2/internal/frontend/runtime/events.go:137 +0x318

goroutine 1 gp=0x140000021c0 m=0 mp=0x105dc9080 [syscall, locked to thread]:
runtime.cgocall(0x1050df608, 0x140006d7d18)
        /usr/local/go/src/runtime/cgocall.go:157 +0x44 fp=0x140006d7ce0 sp=0x140006d7ca0 pc=0x104315844
github.com/wailsapp/wails/v2/internal/frontend/desktop/darwin._Cfunc_RunMainLoop()
        _cgo_gotypes.go:568 +0x30 fp=0x140006d7d10 sp=0x140006d7ce0 pc=0x1048dc390
github.com/wailsapp/wails/v2/internal/frontend/desktop/darwin.(*Frontend).RunMainLoop(0x1400032a300)
        /Users/user/go/pkg/mod/github.com/wailsapp/wails/v2@v2.8.2/internal/frontend/desktop/darwin/frontend.go:69 +0x20 fp=0x140006d7d20 sp=0x140006d7d10 pc=0x1048dfa70
github.com/wailsapp/wails/v2/internal/frontend/devserver.(*DevWebServer).RunMainLoop(0x14000342a20)
        <autogenerated>:1 +0x3c fp=0x140006d7d40 sp=0x140006d7d20 pc=0x1049918dc
github.com/wailsapp/wails/v2/internal/app.(*App).Run(0x1400032e5a0)
        /Users/user/go/pkg/mod/github.com/wailsapp/wails/v2@v2.8.2/internal/app/app_dev.go:33 +0x78 fp=0x140006d7db0 sp=0x140006d7d40 pc=0x10499aee8
github.com/wailsapp/wails/v2/pkg/application.(*Application).Run(0x140002508c0)
        /Users/user/go/pkg/mod/github.com/wailsapp/wails/v2@v2.8.2/pkg/application/application.go:73 +0x17c fp=0x140006d7e50 sp=0x140006d7db0 pc=0x10499e05c
github.com/wailsapp/wails/v2.Run(0x140001b31e0)
        /Users/user/go/pkg/mod/github.com/wailsapp/wails/v2@v2.8.2/wails.go:14 +0x30 fp=0x140006d7e90 sp=0x140006d7e50 pc=0x10499e250
main.main()
        /Users/user/go/src/github.com/user/gui/main.go:18 +0x3d4 fp=0x140006d7f60 sp=0x140006d7e90 pc=0x1050db924
runtime.main()
        /usr/local/go/src/runtime/proc.go:271 +0x228 fp=0x140006d7fd0 sp=0x140006d7f60 pc=0x10434dc28
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x140006d7fd0 sp=0x140006d7fd0 pc=0x104380484

goroutine 2 gp=0x14000002c40 m=nil [force gc (idle)]:
runtime.gopark(0x10558b528, 0x105dc5950, 0x11, 0xa, 0x1)
        /usr/local/go/src/runtime/proc.go:402 +0xe0 fp=0x14000078f70 sp=0x14000078f40 pc=0x10434e080
runtime.goparkunlock(0x105dc5950?, 0x0?, 0x0?, 0x0?)
        /usr/local/go/src/runtime/proc.go:408 +0x34 fp=0x14000078fa0 sp=0x14000078f70 pc=0x10434e114
runtime.forcegchelper()
        /usr/local/go/src/runtime/proc.go:326 +0xb4 fp=0x14000078fd0 sp=0x14000078fa0 pc=0x10434dea4
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x14000078fd0 sp=0x14000078fd0 pc=0x104380484
created by runtime.init.6 in goroutine 1
        /usr/local/go/src/runtime/proc.go:314 +0x24

goroutine 18 gp=0x14000104380 m=nil [GC sweep wait]:
runtime.gopark(0x10558b528, 0x105dc6760, 0xc, 0x9, 0x1)
        /usr/local/go/src/runtime/proc.go:402 +0xe0 fp=0x14000074740 sp=0x14000074710 pc=0x10434e080
runtime.goparkunlock(0x105dc6760?, 0x0?, 0x0?, 0x0?)
        /usr/local/go/src/runtime/proc.go:408 +0x34 fp=0x14000074770 sp=0x14000074740 pc=0x10434e114
runtime.bgsweep(0x14000110000)
        /usr/local/go/src/runtime/mgcsweep.go:318 +0xdc fp=0x140000747b0 sp=0x14000074770 pc=0x104338abc
runtime.gcenable.gowrap1()
        /usr/local/go/src/runtime/mgc.go:203 +0x28 fp=0x140000747d0 sp=0x140000747b0 pc=0x10432d428
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x140000747d0 sp=0x140000747d0 pc=0x104380484
created by runtime.gcenable in goroutine 1
        /usr/local/go/src/runtime/mgc.go:203 +0x6c

goroutine 19 gp=0x14000104540 m=nil [GC scavenge wait]:
runtime.gopark(0x10558b528, 0x105dc77e0, 0xd, 0xa, 0x2)
        /usr/local/go/src/runtime/proc.go:402 +0xe0 fp=0x14000074f20 sp=0x14000074ef0 pc=0x10434e080
runtime.goparkunlock(0x105dc77e0?, 0x68?, 0x1?, 0x0?)
        /usr/local/go/src/runtime/proc.go:408 +0x34 fp=0x14000074f50 sp=0x14000074f20 pc=0x10434e114
runtime.(*scavengerState).park(0x105dc77e0)
        /usr/local/go/src/runtime/mgcscavenge.go:425 +0x4c fp=0x14000074f80 sp=0x14000074f50 pc=0x1043360cc
runtime.bgscavenge(0x14000110000)
        /usr/local/go/src/runtime/mgcscavenge.go:658 +0x60 fp=0x14000074fb0 sp=0x14000074f80 pc=0x104336620
runtime.gcenable.gowrap2()
        /usr/local/go/src/runtime/mgc.go:204 +0x28 fp=0x14000074fd0 sp=0x14000074fb0 pc=0x10432d3c8
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x14000074fd0 sp=0x14000074fd0 pc=0x104380484
created by runtime.gcenable in goroutine 1
        /usr/local/go/src/runtime/mgc.go:204 +0xac

goroutine 20 gp=0x14000104a80 m=nil [finalizer wait]:
runtime.gopark(0x10558b278, 0x105e2ed28, 0x10, 0xa, 0x1)
        /usr/local/go/src/runtime/proc.go:402 +0xe0 fp=0x14000078590 sp=0x14000078560 pc=0x10434e080
runtime.runfinq()
        /usr/local/go/src/runtime/mfinal.go:194 +0xf0 fp=0x140000787d0 sp=0x14000078590 pc=0x10432c5c0
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x140000787d0 sp=0x140000787d0 pc=0x104380484
created by runtime.createfing in goroutine 1
        /usr/local/go/src/runtime/mfinal.go:164 +0x4c