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

cmd/link: panic when adding a rsrc section in Windows PE #39658

Closed
tc-hib opened this issue Jun 17, 2020 · 6 comments
Closed

cmd/link: panic when adding a rsrc section in Windows PE #39658

tc-hib opened this issue Jun 17, 2020 · 6 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-Windows release-blocker
Milestone

Comments

@tc-hib
Copy link

tc-hib commented Jun 17, 2020

What version of Go are you using (go version)?

go version go1.15beta1 windows/amd64

Does this issue reproduce with the latest release?

not 1.14.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GOARCH=amd64
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows

What did you do?

I tried to build a Windows exe file with a syso file containing a rsrc section.

What did you expect to see?

An exe file produced without error.

What did you see instead?

panic: runtime error: slice bounds out of range [72:0]

goroutine 1 [running]:
cmd/link/internal/ld.addpersrc(0xc000091500)
        c:/go/src/cmd/link/internal/ld/pe.go:1490 +0x33d
cmd/link/internal/ld.Asmbpe(0xc000091500)
        c:/go/src/cmd/link/internal/ld/pe.go:1568 +0x253
cmd/link/internal/amd64.asmb2(0xc000091500)
        c:/go/src/cmd/link/internal/amd64/asm.go:842 +0xfa
cmd/link/internal/ld.Main(0x121f860, 0x20, 0x20, 0x1, 0x7, 0x10, 0x0, 0x0, 0x107f875, 0x1b, ...)
        c:/go/src/cmd/link/internal/ld/main.go:349 +0x1509
main.main()
        c:/go/src/cmd/link/main.go:68 +0x1fc```
@cherrymui
Copy link
Member

Thanks for the report. Would it be possible to share your syso file, or perhaps any syso file that contains a rsrc section? So I'll try to reproduce it myself for debugging. Thanks.

@cherrymui cherrymui added this to the Go1.15 milestone Jun 18, 2020
@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 18, 2020
@tc-hib
Copy link
Author

tc-hib commented Jun 18, 2020

Sure, here it is.

linker_rsrc.zip

@andybons andybons changed the title Linker panic when adding a rsrc section in Windows PE cmd/link: panic when adding a rsrc section in Windows PE Jun 18, 2020
@gopherbot
Copy link

Change https://golang.org/cl/238779 mentions this issue: cmd/link: use sym.Symbol in addpersrc

@cherrymui
Copy link
Member

@tc-hib thanks very much for the file. CL https://golang.org/cl/238779 fixes the linker crash. Could you try that and check if the content of the rsrc is generated correctly? Thanks.

@tc-hib
Copy link
Author

tc-hib commented Jun 19, 2020

It works, thank you very much.
My application has an icon and version information. It is readable by resource extractors and got correctly compressed with UPX.
So I'd say the rsrc section is perfectly integrated.

I've read the comments in the CL.
Here are two syso files without any copyright notice.
One is very small, the other one has a manifest.
rsrc_syso.zip

You can create a syso file with windres or rsrc indeed.
I didn't try windres, but akavel/rsrc seems to produce not so good rsrc sections, most probably because of a lack of alignment of resource data.
There's also goversioninfo which is based on akavel/rsrc.

@cherrymui
Copy link
Member

@tc-hib thanks for confirming! I managed to create a rsrc syso using windres on the builder machine. Thanks for the information.

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jun 19, 2020
@golang golang locked and limited conversation to collaborators Jun 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-Windows release-blocker
Projects
None yet
Development

No branches or pull requests

5 participants