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

Comments

@tc-hib
Copy link

@tc-hib 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
Contributor

@cherrymui cherrymui commented Jun 18, 2020

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
@tc-hib
Copy link
Author

@tc-hib 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
@andybons andybons added the OS-Windows label Jun 18, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 18, 2020

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

@cherrymui
Copy link
Contributor

@cherrymui cherrymui commented Jun 18, 2020

@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 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.

@gopherbot gopherbot closed this in f2bba30 Jun 19, 2020
@cherrymui
Copy link
Contributor

@cherrymui cherrymui commented Jun 19, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.