runtime: function textOff returns incorrect value if multiple text sections are present [1.12 backport] #35210
The applications which require multiple text sections are Openshift and Kubernetes because of the unusually large text sections they generate. When the error occurs, it is difficult to debug and there is no workaround. Also, these applications require a backlevel Go version for their builds, for example Openshift is using Go 1.12 at this time, so I doubt telling them to move up to the latest version is acceptable.
The fix is in this case is extremely simple and safe.
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 '<'. Fixes #35210 Change-Id: I114633fd734563d38f4e842dd884c6c239f73c95 Reviewed-on: https://go-review.googlesource.com/c/go/+/203817 Run-TryBot: Lynn Boger <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org> Reviewed-by: Ian Lance Taylor <email@example.com> Reviewed-by: Cherry Zhang <firstname.lastname@example.org> (cherry picked from commit 0ae9389) Reviewed-on: https://go-review.googlesource.com/c/go/+/203818 Run-TryBot: Carlos Amedee <email@example.com> Reviewed-by: Keith Randall <firstname.lastname@example.org>