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
runtime: function textOff returns incorrect value if multiple text sections are present #35207
Comments
Change https://golang.org/cl/203817 mentions this issue: |
The segv occurs in encoding/json/decode.go function literalStore when trying to invoke the UnmarshalJSON function. The address of that function is incorrect because in the function indirect this code:
depends on the tab lookup using textOff and gets an invalid value. |
@gopherbot Please backport to go 1.13 and go 1.12. |
Backport issue(s) opened: #35210 (for 1.12), #35211 (for 1.13). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
If a compilation has multiple text sections, code in textOff must compare the offset argument against the range for each text section to determine which one it is in. The comparison looks like this: if uintptr(off) >= sectaddr && uintptr(off) <= sectaddr+sectlen If the off value being compared is equal to sectaddr+sectlen then it is not within the range of the text section but after it. The comparison should be just '<'. Updates #35207 Change-Id: I114633fd734563d38f4e842dd884c6c239f73c95 Reviewed-on: https://go-review.googlesource.com/c/go/+/203817 Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This fix for this is already upstream in CL 203817. Backports are pending. |
@laboger Should this issue be closed? Is it resolved now on tip? |
Yes, resolved on tip. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
The incorrect code exists in the latest release. The failure will only happen when trying to look up the textOff for an off that is at the end of a text section if there are multiple text sections. Multiple text sections are not common but do happen in Kubernetes and Openshift.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Built and ran the tests for Openshift. By default -race is used for testing.
To run all the tests:
To run the test that just fails:
What did you expect to see?
No failures.
What did you see instead?
I have a fix for this. After debugging I found that the problem is in runtime/type.go function textOff where it looks up the text offset from an offset. If the 'off' happens to be the last value in the text section, the wrong value is returned.
The text was updated successfully, but these errors were encountered: