yaegi icon indicating copy to clipboard operation
yaegi copied to clipboard

reflect.Value.Set using value obtained using unexported field

Open darkweak opened this issue 2 years ago • 0 comments

The following program sample.go triggers an unexpected result

type Configuration struct {
	Logger          *zap.Logger
}

// GetLogger get the logger
func (c *Configuration) GetLogger() *zap.Logger {
	return c.Logger
}

// ...

var c Configuration

// ...

c.GetLogger().Debug("My debug")

Expected result

It should debug, but it throws the following error.

Got

traefik_1  | time="2021-08-11T23:56:17Z" level=error msg="Error in Go routine: reflect: reflect.Value.Set using value obtained using unexported field"
traefik_1  | time="2021-08-11T23:56:17Z" level=error msg="Stack: goroutine 49 [running]:\nruntime/debug.Stack(0xc0000e0000, 0x36115ba, 0x17)\n\t/usr/local/go/src/runtime/debug/stack.go:24 +0x9f\ngithub.com/traefik/traefik/v2/pkg/safe.defaultRecoverGoroutine(0x2eae980, 0xc00368cbf0)\n\t/go/src/github.com/traefik/traefik/pkg/safe/routine.go:66 +0xb4\ngithub.com/traefik/traefik/v2/pkg/safe.GoWithRecover.func1.1(0x37352a0)\n\t/go/src/github.com/traefik/traefik/pkg/safe/routine.go:56 +0x5a\npanic(0x2eae980, 0xc00368cbf0)\n\t/usr/local/go/src/runtime/panic.go:965 +0x1b9\ngithub.com/traefik/yaegi/interp.runCfg.func1(0xc003211970, 0xc0012e7b00, 0xc003698d40)\n\t/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:184 +0x253\npanic(0x2eae980, 0xc00368cbf0)\n\t/usr/local/go/src/runtime/panic.go:965 +0x1b9\ngithub.com/traefik/yaegi/interp.runCfg.func1(0xc003211ef0, 0xc0021d0e00, 0xc003698b18)\n\t/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:184 +0x253\npanic(0x2eae980, 0xc00368cbf0)\n\t/usr/local/go/src/runtime/panic.go:965 +0x1b9\ngithub.com/traefik/yaegi/interp.runCfg.func1(0xc0036a1080, 0xc001897d00, 0xc0036988f0)\n\t/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:184 +0x253\npanic(0x2eae980, 0xc00368cbf0)\n\t/usr/local/go/src/runtime/panic.go:965 +0x1b9\ngithub.com/traefik/yaegi/interp.runCfg.func1(0xc0036a1a20, 0xc0018ad200, 0xc0036986c8)\n\t/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:184 +0x253\npanic(0x2eae980, 0xc00368cbf0)\n\t/usr/local/go/src/runtime/panic.go:965 +0x1b9\ngithub.com/traefik/yaegi/interp.runCfg.func1(0xc0036a1ad0, 0xc001a44700, 0xc0036984a0)\n\t/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:184 +0x253\npanic(0x2eae980, 0xc00368cbf0)\n\t/usr/local/go/src/runtime/panic.go:965 +0x1b9\ngithub.com/traefik/yaegi/interp.runCfg.func1(0xc0036a1b80, 0xc001a47a00, 0xc003698278)\n\t/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:184 +0x253\npanic(0x2eae980, 0xc00368cbf0)\n\t/usr/local/go/src/runtime/panic.go:965 +0x1b9\nreflect.flag.mustBeExportedSlow(0x26b3)\n\t/usr/local/go/src/reflect/value.go:238 +0x131\nreflect.flag.mustBeExported(...)\n\t/usr/local/go/src/reflect/value.go:229\nreflect.Value.Set(0x2e84480, 0xc00369a790, 0x193, 0x35b2ec0, 0xc0036a61e8, 0x26b3)\n\t/usr/local/go/src/reflect/value.go:1559 +0x56\ngithub.com/traefik/yaegi/interp.genInterfaceWrapper.func1(0xc0036a1b80, 0x2e3eda0, 0xc00369a660, 0x197)\n\t/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:1017 +0x4e5\ngithub.com/traefik/yaegi/interp._append.func2(0xc0036a1b80, 0xc00159d560)\n\t/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:2974 +0xcd\ngithub.com/traefik/yaegi/interp.runCfg(0xc001a47a00, 0xc0036a1b80)\n\t/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:190 +0x87\ngithub.com/traefik/yaegi/interp.call.func6(0xc0036a1ad0, 0xc00369e9e0)\n\t/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:1280 +0xdc5\ngithub.com/traefik/yaegi/interp.runCfg(0xc001a44700, 0xc0036a1ad0)\n\t/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:190 +0x87\ngithub.com/traefik/yaegi/interp.call.func6(0xc0036a1a20, 0xc001546a10)\n\t/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:1280 +0xdc5\ngithub.com/traefik/yaegi/interp.runCfg(0xc0018ad200, 0xc0036a1a20)\n\t/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:190 +0x87\ngithub.com/traefik/yaegi/interp.call.func6(0xc0036a1080, 0xc0015464d0)\n\t/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:1280 +0xdc5\ngithub.com/traefik/yaegi/interp.runCfg(0xc001897d00, 0xc0036a1080)\n\t/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:190 +0x87\ngithub.com/traefik/yaegi/interp.call.func6(0xc003211ef0, 0xc0030daee0)\n\t/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:1280 +0xdc5\ngithub.com/traefik/yaegi/interp.runCfg(0xc0021d0e00, 0xc003211ef0)\n\t/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:190 +0x87\ngithub.com/traefik/yaegi/interp.call.func6(0xc003211970, 0xc003234070)\n\t/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:1280 +0xdc5\ngithub.com/traefik/yaegi/interp.runCfg(0xc0012e7b00, 0xc003211970)\n\t/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:190 +0x87\ngithub.com/traefik/yaegi/interp.genFunctionWrapper.func2.1(0xc00323aba0, 0x4, 0x4, 0xc00323aba0, 0x2f8700, 0x2f0c700)\n\t/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:951 +0x3e8\nreflect.Value.call(0xc0030e5780, 0xc00365de60, 0x13, 0x35d4446, 0x4, 0xc0032b5428, 0x4, 0x4, 0xc0032b5350, 0x40e71b, ...)\n\t/usr/local/go/src/reflect/value.go:476 +0x8e7\nreflect.Value.Call(0xc0030e5780, 0xc00365de60, 0x13, 0xc0032b5428, 0x4, 0x4, 0xc00041f101, 0xc0030f1bd0, 0xc0032b54b0)\n\t/usr/local/go/src/reflect/value.go:337 +0xb9\ngithub.com/traefik/traefik/v2/pkg/plugins.(*Middleware).NewHandler(0xc00365e380, 0x3b9ace0, 0xc00365d9e0, 0x3b2dd00, 0xc00365d9b0, 0xc0032b54f0, 0x411418, 0x20, 0x31dcc20)\n\t/go/src/github.com/traefik/traefik/pkg/plugins/middlewares.go:82 +0x2e7\ngithub.com/traefik/traefik/v2/pkg/server/middleware.(*Builder).buildConstructor.func23(0x3b2dd00, 0xc00365d9b0, 0xc0030f1bd0, 0x0, 0x0, 0x2e463e0)\n\t/go/src/github.com/traefik/traefik/pkg/server/middleware/middlewares.go:359 +0x4b\ngithub.com/traefik/traefik/v2/pkg/middlewares/tracing.Wrap.func1(0x3b2dd00, 0xc00365d9b0, 0xc00365d9e0, 0xc00156d2c0, 0x16, 0xc0030cf9c0)\n\t/go/src/github.com/traefik/traefik/pkg/middlewares/tracing/wrapper.go:24 +0x71\ngithub.com/traefik/traefik/v2/pkg/server/middleware.(*Builder).BuildChain.func1(0x3b2dd00, 0xc00365d9b0, 0x3b2dd00, 0xc00365d9b0, 0x0, 0x0)\n\t/go/src/github.com/traefik/traefik/pkg/server/middleware/middlewares.go:80 +0x22b\ngithub.com/containous/alice.Chain.Then(0xc0030f15a0, 0x2, 0x2, 0x3b2da60, 0xc0030f1590, 0x1, 0xc0031c7770, 0x0, 0x0)\n\t/go/pkg/mod/github.com/containous/[email protected]/chain.go:51 +0x90\ngithub.com/traefik/traefik/v2/pkg/server/router.(*Manager).buildHTTPHandler(0xc0032b5d30, 0x3b9ace0, 0xc00365d530, 0xc0030c9180, 0xc0026b91a0, 0xb, 0xc0032b5850, 0x40ed65, 0x34220e0, 0x354c5a0)\n\t/go/src/github.com/traefik/traefik/pkg/server/router/router.go:190 +0x59b\ngithub.com/traefik/traefik/v2/pkg/server/router.(*Manager).buildRouterHandler(0xc003699d30, 0x3b9ace0, 0xc00365d530, 0xc0026b91a0, 0xb, 0xc0030c9180, 0xc00365d530, 0x0, 0x5780e40, 0x0)\n\t/go/src/github.com/traefik/traefik/pkg/server/router/router.go:144 +0xd8\ngithub.com/traefik/traefik/v2/pkg/server/router.(*Manager).buildEntryPointHandler(0xc003699d30, 0x3b9ace0, 0xc00365d3e0, 0xc00365d2f0, 0x1, 0x3b9ace0, 0xc00365d3e0, 0xc00365d1d0)\n\t/go/src/github.com/traefik/traefik/pkg/server/router/router.go:114 +0x237\ngithub.com/traefik/traefik/v2/pkg/server/router.(*Manager).BuildHandlers(0xc003699d30, 0x3b9ac70, 0xc000056040, 0xc0030f1110, 0x1, 0x1, 0x0, 0x0)\n\t/go/src/github.com/traefik/traefik/pkg/server/router/router.go:68 +0x1fa\ngithub.com/traefik/traefik/v2/pkg/server.(*RouterFactory).CreateRouters(0xc0032341c0, 0xc00365e0c0, 0xc0032af840, 0xc0032ce900)\n\t/go/src/github.com/traefik/traefik/pkg/server/routerfactory.go:77 +0x24b\nmain.switchRouter.func1(0xc0032ce8d0, 0xc0032b0bb8, 0xc0032af840, 0xc0032ce900)\n\t/go/src/github.com/traefik/traefik/cmd/traefik/traefik.go:374 +0x95\ngithub.com/traefik/traefik/v2/pkg/server.(*ConfigurationWatcher).loadMessage(0xc0001ab360, 0x35df11b, 0x8, 0xc0032ca120)\n\t/go/src/github.com/traefik/traefik/pkg/server/configurationwatcher.go:155 +0x20d\ngithub.com/traefik/traefik/v2/pkg/server.(*ConfigurationWatcher).listenConfigurations(0xc0001ab360, 0x3b9ac38, 0xc0001d13c0)\n\t/go/src/github.com/traefik/traefik/pkg/server/configurationwatcher.go:135 +0x51\ngithub.com/traefik/traefik/v2/pkg/safe.(*Pool).GoCtx.func1()\n\t/go/src/github.com/traefik/traefik/pkg/safe/routine.go:36 +0x64\ngithub.com/traefik/traefik/v2/pkg/safe.GoWithRecover.func1(0x37352a0, 0xc0031c6708)\n\t/go/src/github.com/traefik/traefik/pkg/safe/routine.go:59 +0x4f\ncreated by github.com/traefik/traefik/v2/pkg/safe.GoWithRecover\n\t/go/src/github.com/traefik/traefik/pkg/safe/routine.go:53 +0x49\n"

Yaegi Version

37fe3422d8de70e793e1c52b8364721afca3b764

Additional Notes

No response

darkweak avatar Aug 12 '21 00:08 darkweak