Skip to content
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

x/pkgsite/cmd/pkgsite: panic for "multiple registrations" when running locally #64903

Closed
zombiezen opened this issue Dec 30, 2023 · 10 comments
Closed
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@zombiezen
Copy link
Contributor

IIUC from #49212, godoc is deprecated and I should be running pkgsite locally. I'm having trouble getting it to serve docs from a local project and seeing symptoms similar to #53323, but that issue has long since been fixed.

What did you do?

$ git clone https://github.com/zombiezen/go-ini.git
$ cd go-ini && git checkout 23a6472a8275fb654b81d9d8a0650641c44a948f
$ pkgsite

What did you expect to see?

2023/12/30 09:30:21 Info: Listening on addr http://localhost:8080

What did you see instead?

2023/12/30 09:29:47 Info: go/packages.Load(["all"]) loaded 65 packages from . in 159.541853ms
2023/12/30 09:29:47 Info: go/packages.Load(std) loaded 275 packages from  in 298.313706ms
2023/12/30 09:29:47 Info: FetchDataSource: fetching zombiezen.com/go/ini@v0.0.0
2023/12/30 09:29:47 Info: FetchDataSource: fetching std@v0.0.0
2023/12/30 09:29:47 Info: licenses.Detector.paths: stat .: no such file or directory
2023/12/30 09:29:47 Info: licenses.Detector.paths: stat .: no such file or directory
2023/12/30 09:29:47 Info: FetchDataSource: fetched std@v0.0.0 using *fetch.goPackagesModuleGetter in 2.208106ms with error FetchModule("std", "v0.0.0"): processModuleContents("std", "v0.0.0"): extractPackages(ctx, "std", "v0.0.0", r, d): no files: module contains 0 packages: bad module
panic: http: multiple registrations for /home/light/src/zombiezen.com/go/ini/

goroutine 1 [running]:
net/http.(*ServeMux).Handle(0xc000784180, {0xc0006a7500, 0x25}, {0x11dfec0?, 0xc000a7e1e0})
        net/http/server.go:2530 +0x219
golang.org/x/pkgsite/internal/frontend.(*Server).InstallFS(0xc000611680, {0xc0001343c0, 0x24}, {0x11e0e20?, 0xc0000a4050?})
        golang.org/x/pkgsite/internal/frontend/server.go:311 +0x177
main.newServer({0xc0003d26c0?, 0x3, 0x1?}, {0xc000594040?, 0x1, 0x1}, 0x0?)
        golang.org/x/pkgsite/cmd/pkgsite/main.go:444 +0x505
main.buildServer({0x11e6440, 0x164ee40}, {{0xc00027f4c0, 0x1, 0x1}, 0x0, 0x0, {0x0, 0x0}, 0x1, ...})
        golang.org/x/pkgsite/cmd/pkgsite/main.go:251 +0x4a7
main.main()
        golang.org/x/pkgsite/cmd/pkgsite/main.go:146 +0x3eb

Additional context

pkgsite was built with commit golang/pkgsite@475d4c5.

$ go version -m `which pkgsite`
/home/light/.nix-profile/bin/pkgsite: go1.21.4
        path    golang.org/x/pkgsite/cmd/pkgsite
        mod     golang.org/x/pkgsite    (devel)
        dep     github.com/google/licensecheck  v0.3.1
        dep     github.com/google/safehtml      v0.0.3-0.20211026203422-d6f0e11a5516
        dep     golang.org/x/mod        v0.14.0
        dep     golang.org/x/net        v0.19.0
        dep     golang.org/x/sync       v0.5.0
        dep     golang.org/x/text       v0.14.0
        dep     golang.org/x/tools      v0.16.0
        dep     rsc.io/markdown v0.0.0-20231214224604-88bb533a6020
        build   -buildmode=exe
        build   -compiler=gc
        build   -trimpath=true
        build   DefaultGODEBUG=panicnil=1
        build   CGO_ENABLED=1
        build   GOARCH=amd64
        build   GOOS=linux
        build   GOAMD64=v1
$ go version
go version go1.21.4 linux/amd64
@gopherbot gopherbot added this to the Unreleased milestone Dec 30, 2023
@mauri870 mauri870 added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 31, 2023
@mauri870
Copy link
Member

mauri870 commented Jan 2, 2024

I tried to reproduce this locally with no avail. Maybe the true error is extractPackages(ctx, "std", "v0.0.0", r, d): no files: module contains 0 packages: bad module and panic is just a red herring?

Can you try running GODEBUG=installgoroot=all go install std before invoking pkgsite? Thanks

@seankhliao
Copy link
Member

I can reproduce it, and it does appear to be related to the go sdk since pkgsite -gorepo ./sdk/gotip works for me

@seankhliao
Copy link
Member

cc @matloob

from bisect looks like CL 517915

@matloob
Copy link
Contributor

matloob commented Jan 2, 2024

I can't reproduce this. @seankhliao did you do anything special to reproduce?

@zombiezen
Copy link
Contributor Author

If it's relevant, I'm using Nix-provided Go. The exact derivation I'm using is https://github.com/zombiezen/dotfiles/tree/106d749fa46359bb089db06003f736e7cda521c5/nix

nix build 'github:zombiezen/dotfiles/106d749fa46359bb089db06003f736e7cda521c5?dir=nix#pkgsite'

@matloob
Copy link
Contributor

matloob commented Jan 2, 2024

Hm I'm not familiar with nix. I guess it's possible that the version of go you're using could affect things but I'm not exactly sure how.

@seankhliao
Copy link
Member

I think it's when pkgsite is built with -trimpath (which i have set via GOFLAGS):

» docker run --rm -it alpine
/ # apk add git go 
fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/community/x86_64/APKINDEX.tar.gz
(1/24) Installing ca-certificates (20230506-r0)
(2/24) Installing brotli-libs (1.1.0-r1)
(3/24) Installing c-ares (1.22.1-r0)
(4/24) Installing libunistring (1.1-r2)
(5/24) Installing libidn2 (2.3.4-r4)
(6/24) Installing nghttp2-libs (1.58.0-r0)
(7/24) Installing libcurl (8.5.0-r0)
(8/24) Installing libexpat (2.5.0-r2)
(9/24) Installing pcre2 (10.42-r2)
(10/24) Installing git (2.43.0-r0)
(11/24) Installing libgcc (13.2.1_git20231014-r0)
(12/24) Installing jansson (2.14-r4)
(13/24) Installing libstdc++ (13.2.1_git20231014-r0)
(14/24) Installing zstd-libs (1.5.5-r8)
(15/24) Installing binutils (2.41-r0)
(16/24) Installing libgomp (13.2.1_git20231014-r0)
(17/24) Installing libatomic (13.2.1_git20231014-r0)
(18/24) Installing gmp (6.3.0-r0)
(19/24) Installing isl26 (0.26-r1)
(20/24) Installing mpfr4 (4.2.1-r0)
(21/24) Installing mpc1 (1.3.1-r1)
(22/24) Installing gcc (13.2.1_git20231014-r0)
(23/24) Installing musl-dev (1.2.4_git20230717-r4)
(24/24) Installing go (1.21.5-r0)
Executing busybox-1.36.1-r15.trigger
Executing ca-certificates-20230506-r0.trigger
OK: 344 MiB in 39 packages
/ # cd
~ # git clone https://github.com/zombiezen/go-ini.git
Cloning into 'go-ini'...
remote: Enumerating objects: 38, done.
remote: Counting objects: 100% (38/38), done.
remote: Compressing objects: 100% (24/24), done.
remote: Total 38 (delta 14), reused 35 (delta 11), pack-reused 0
Receiving objects: 100% (38/38), 20.66 KiB | 556.00 KiB/s, done.
Resolving deltas: 100% (14/14), done.
~ # cd go-ini && git checkout 23a6472a8275fb654b81d9d8a0650641c44a948f
Note: switching to '23a6472a8275fb654b81d9d8a0650641c44a948f'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 23a6472 Pass file name to Parse in ParseFiles
~/go-ini # go install -trimpath golang.org/x/pkgsite/cmd/pkgsite@master
go: downloading golang.org/x/pkgsite v0.0.0-20231224130350-475d4c57676e
go: downloading github.com/google/safehtml v0.0.3-0.20211026203422-d6f0e11a5516
go: downloading golang.org/x/mod v0.14.0
go: downloading golang.org/x/net v0.19.0
go: downloading golang.org/x/text v0.14.0
go: downloading rsc.io/markdown v0.0.0-20231214224604-88bb533a6020
go: downloading golang.org/x/sync v0.5.0
go: downloading golang.org/x/tools v0.16.0
go: downloading github.com/google/licensecheck v0.3.1
~/go-ini # ~/go/bin/pkgsite 
2024/01/02 21:35:04 Info: go/packages.Load(["all"]) loaded 59 packages from . in 30.21062709s
2024/01/02 21:35:04 Info: go/packages.Load(std) loaded 273 packages from  in 630.710124ms
2024/01/02 21:35:04 Info: FetchDataSource: fetching zombiezen.com/go/ini@v0.0.0
2024/01/02 21:35:04 Info: FetchDataSource: fetching std@v0.0.0
2024/01/02 21:35:04 Info: licenses.Detector.paths: stat .: no such file or directory
2024/01/02 21:35:04 Info: licenses.Detector.paths: stat .: no such file or directory
2024/01/02 21:35:04 Info: FetchDataSource: fetched std@v0.0.0 using *fetch.goPackagesModuleGetter in 3.131573ms with error FetchModule("std", "v0.0.0"): processModuleContents("std", "v0.0.0"): extractPackages(ctx, "std", "v0.0.0", r, d): no files: module contains 0 packages: bad module
panic: http: multiple registrations for /root/go-ini/

goroutine 1 [running]:
net/http.(*ServeMux).Handle(0xc000809300, {0xc00098a0e0, 0xd}, {0x11ded20?, 0xc000419d70})
	net/http/server.go:2530 +0x219
golang.org/x/pkgsite/internal/frontend.(*Server).InstallFS(0xc000789c20, {0xc0004081b0, 0xc}, {0x11dfc80?, 0xc0000968c0?})
	golang.org/x/pkgsite@v0.0.0-20231224130350-475d4c57676e/internal/frontend/server.go:311 +0x177
main.newServer({0xc0003d72c0?, 0x3, 0x1?}, {0xc00030d160?, 0x1, 0x1}, 0x0?)
	golang.org/x/pkgsite@v0.0.0-20231224130350-475d4c57676e/cmd/pkgsite/main.go:444 +0x505
main.buildServer({0x11e52a0, 0x164df60}, {{0xc000255510, 0x1, 0x1}, 0x0, 0x0, {0x0, 0x0}, 0x1, ...})
	golang.org/x/pkgsite@v0.0.0-20231224130350-475d4c57676e/cmd/pkgsite/main.go:251 +0x4a7
main.main()
	golang.org/x/pkgsite@v0.0.0-20231224130350-475d4c57676e/cmd/pkgsite/main.go:146 +0x3eb

@gopherbot
Copy link

Change https://go.dev/cl/554195 mentions this issue: cmd/pkgsite: fix case where we don't have runtime.GOROOT()

@matloob
Copy link
Contributor

matloob commented Jan 4, 2024

I sent CL 554195 to fix the behavior with -trimpath. Hopefully that's the root cause of the error you're seeing.

zombiezen added a commit to zombiezen/dotfiles that referenced this issue Jan 6, 2024
@zombiezen
Copy link
Contributor Author

I've patched in your CL and this does indeed fix the issue. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants