-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plugin: spurious version-mismatch error for packages that differ only in debug information #31278
Comments
This interferes with plugin loading. See: - golang/go#31278 - golang/go#30531 - golang/go#28983 Signed-off-by: Marcelo E. Magallon <[email protected]>
Have you verified that CC @jayconrod |
Thanks for looking at this Bryan. Each module has a go.mod file that cotains:
the line is the same in both cases: https://github.com/mem/go-plugin-modules/blob/master/go-plugin-hook/go.mod#L5 The output of
in both cases. If I look at the stored hashes by looking at the data stored in the ELF data, for the program, I see:
For the plugin that works (the one without the -mod=vendor flag), I see:
(they match) For the plugin that does not work (with the -mod=vendor flag), I see:
(does not match). I've been looking the linker code but I can't figure out how these hashes are computed. Investigating a little further (and guessing a lot), I can get this to work if I pass It does not interoperate, and I'm not sure if it should. What I mean is that if I build the program with I gues the questions are this point are:
|
Additional info. For the non-working case, the hashes are:
Adding -trimpath to get it working:
Since -trimpath doesn't seem to have an effect with / without -mod=vendor, I'm guessing $GOPATH/pkg/mod/ is somehow involved in the computation of the hash? Just to be clear, everything above has been done without GOPATH set (so it's using the $HOME/go default). If I set GOPATH to something (just to hold the pkg/mod files in a different directory), I can see the hashes in the "without -mod=vendor" case changing, but the "with -mod=vendor" case stays the same. So the end result is that I have to use -mod=vendor (otherwise I have to build using the same path for the code) and I have to set -trimpath (otherwise the code cannot be loaded). Should this be captured in a document? |
Probably at least one difference here is in the debug information, which by default includes the full file paths. That's why you need If that's correct, then you may find that if you set |
@ianlancetaylor and @cherrymui: is there something we can do in the |
As far as I can tell the hash value is based only on the externally visible ABI. Changes in the debug information shouldn't affect it. But I don't think anybody really understands this other than @crawshaw. |
While revisiting this for a different reason, I also noticed that -trimpath is a string ( The build command uses the -trimpath flag internally, calling compile for example as That means if I pass Does this matter? |
Checking, thanks @bcmills |
sounds like the solution is -trimpath. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
The code to reproduce the issue is available at https://github.com/mem/go-plugin-modules
You can use the makefile in there to build the code and run the tests using
make test
.When building a program and a plugin using the -mod=vendor flag (and vendoring the corresponding packages in the respective modules using
go mod vendor
), the plugin code fails to load:And then running this program as:
produces the error:
What did you expect to see?
The plugin is loaded and the code runs. This is demonstrated in the above code by running
make test-no-vendor
, which simply does not pass the-mod=vendor
flag when building.What did you see instead?
It seems the recorded import path when passing -mod=vendor is different.
This is related (duplicate?) of #28983, but I found that issue only until I was submitting this one, so I think there's missing documentation that explains what the issue is and how it should be dealt with.
The text was updated successfully, but these errors were encountered: