golang-fips / go

Repository for FIPS enabled Go using OpenSSL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

runtime/pprof TestConvert*Profile fails when dynamically linked

dbenoit17 opened this issue · comments

TestConvertCPUProfile and TestConvertMemProfile both fail when dynamically linked in Fedora and ubi9, because the executable segment (r-xp in /proc/self/maps) is mapped as the second section whereas with earlier versions of system libraries it is mapped as the first.

https://github.com/dbenoit17/openssl-fips/actions/runs/3146239220/jobs/5114463156#step:13:394

The following patch appears to resolve the issue, but it could potentially cause issues in different configurations. Might be a good starting point to work with:

diff --git a/src/runtime/pprof/proto_test.go b/src/runtime/pprof/proto_test.go
index 84a051a..d640250 100644
--- a/src/runtime/pprof/proto_test.go
+++ b/src/runtime/pprof/proto_test.go
@@ -95,11 +95,11 @@ func testPCs(t *testing.T) (addr1, addr2 uint64, map1, map2 *profile.Mapping) {
                        // region of memory.
                        t.Skipf("need 2 or more mappings, got %v", len(mprof.Mapping))
                }
-               addr1 = mprof.Mapping[0].Start
-               map1 = mprof.Mapping[0]
+               addr1 = mprof.Mapping[1].Start
+               map1 = mprof.Mapping[1]
                map1.BuildID, _ = elfBuildID(map1.File)
-               addr2 = mprof.Mapping[1].Start
-               map2 = mprof.Mapping[1]
+               addr2 = mprof.Mapping[2].Start
+               map2 = mprof.Mapping[2]
                map2.BuildID, _ = elfBuildID(map2.File)
        case "js":
                addr1 = uint64(abi.FuncPCABIInternal(f1))  

I think we should skip this test in ubi9 for now as we work towards an upstream fix.

So it looks like this was fixed upstream in the master branch via https://go-review.googlesource.com/c/go/+/424295. I suggest we carry this patch in our downstream 1.19 release branch. I'll open a PR for that.