[jira] [Work logged] (BEAM-8242) Go: unregistered Go functions fail when using -buildmode=pie
[ https://issues.apache.org/jira/browse/BEAM-8242?focusedWorklogId=314606=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-314606 ] ASF GitHub Bot logged work on BEAM-8242: Author: ASF GitHub Bot Created on: 18/Sep/19 19:46 Start Date: 18/Sep/19 19:46 Worklog Time Spent: 10m Work Description: ianlancetaylor commented on issue #9585: [BEAM-8242] Support -buildmode=pie with unregistered Go functions URL: https://github.com/apache/beam/pull/9585#issuecomment-532837597 Thanks! This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 314606) Time Spent: 1.5h (was: 1h 20m) > Go: unregistered Go functions fail when using -buildmode=pie > > > Key: BEAM-8242 > URL: https://issues.apache.org/jira/browse/BEAM-8242 > Project: Beam > Issue Type: Bug > Components: sdk-go >Affects Versions: 2.15.0 > Environment: GNU/Linux >Reporter: Ian Lance Taylor >Assignee: Robert Burke >Priority: Major > Original Estimate: 0h > Time Spent: 1.5h > Remaining Estimate: 0h > > If a Go program is built with -buildmode=pie, the code that transfers an > unregistered function fails. It looks up the symbol in the symbol table, but > that is not the location of the function at execution time. This causes a > program crash when calling the function. > I have a patch for this problem that I will send shortly. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-8242) Go: unregistered Go functions fail when using -buildmode=pie
[ https://issues.apache.org/jira/browse/BEAM-8242?focusedWorklogId=314601=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-314601 ] ASF GitHub Bot logged work on BEAM-8242: Author: ASF GitHub Bot Created on: 18/Sep/19 19:36 Start Date: 18/Sep/19 19:36 Worklog Time Spent: 10m Work Description: lostluck commented on pull request #9585: [BEAM-8242] Support -buildmode=pie with unregistered Go functions URL: https://github.com/apache/beam/pull/9585 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 314601) Time Spent: 1h 20m (was: 1h 10m) > Go: unregistered Go functions fail when using -buildmode=pie > > > Key: BEAM-8242 > URL: https://issues.apache.org/jira/browse/BEAM-8242 > Project: Beam > Issue Type: Bug > Components: sdk-go >Affects Versions: 2.15.0 > Environment: GNU/Linux >Reporter: Ian Lance Taylor >Assignee: Robert Burke >Priority: Major > Original Estimate: 0h > Time Spent: 1h 20m > Remaining Estimate: 0h > > If a Go program is built with -buildmode=pie, the code that transfers an > unregistered function fails. It looks up the symbol in the symbol table, but > that is not the location of the function at execution time. This causes a > program crash when calling the function. > I have a patch for this problem that I will send shortly. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-8242) Go: unregistered Go functions fail when using -buildmode=pie
[ https://issues.apache.org/jira/browse/BEAM-8242?focusedWorklogId=314593=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-314593 ] ASF GitHub Bot logged work on BEAM-8242: Author: ASF GitHub Bot Created on: 18/Sep/19 19:25 Start Date: 18/Sep/19 19:25 Worklog Time Spent: 10m Work Description: ianlancetaylor commented on pull request #9585: [BEAM-8242] Support -buildmode=pie with unregistered Go functions URL: https://github.com/apache/beam/pull/9585#discussion_r325852241 ## File path: sdks/go/pkg/beam/core/util/symtab/symtab_test.go ## @@ -0,0 +1,115 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +//http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package symtab + +import ( + "io/ioutil" + "os" + "os/exec" + "path/filepath" + "runtime" + "strings" + "testing" +) + +// TestSym2Addr builds and runs this test program. +const testprog = ` +package main + +import ( + "fmt" + "os" + "runtime" + + "github.com/apache/beam/sdks/go/pkg/beam/core/util/symtab" +) + +func die(format string, a ...interface{}) { + fmt.Fprintf(os.Stderr, format, a...) + os.Exit(1) +} + +func main() { + syms, err := symtab.New(os.Args[0]) + if err != nil { + die("%s: could not read symbols: %v", os.Args[0], err) + } + + symPC, err := syms.Sym2Addr("main.main") + if err != nil { + die("Sym2Addr(%q) failed: %v", "main.main", err) + } + + runtimePC := fnaddr() + if symPC != runtimePC { + die("PC from symbol table %x != runtime PC %x", symPC, runtimePC) + } +} + +// fnaddr returns the entry address of its caller. +func fnaddr() uintptr { + var pcs [2]uintptr + n := runtime.Callers(2, pcs[:]) + frames := runtime.CallersFrames(pcs[:n]) + frame, _ := frames.Next() + return frame.Func.Entry() +} +` + +func TestSym2Addr(t *testing.T) { + f, err := ioutil.TempFile("", "TestSym2Addr*.go") + if err != nil { + t.Fatal(err) + } + + fname := f.Name() + defer os.Remove(fname) + + if _, err := f.WriteString(testprog); err != nil { + t.Fatal(err) + } + if err := f.Close(); err != nil { + t.Fatal(err) + } + + bin := strings.TrimSuffix(fname, ".go") + defer os.Remove(bin) + + gotool := filepath.Join(runtime.GOROOT(), "bin", "go") + + for _, arg := range []string{"", "-buildmode=pie"} { Review comment: Done. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 314593) Time Spent: 1h (was: 50m) > Go: unregistered Go functions fail when using -buildmode=pie > > > Key: BEAM-8242 > URL: https://issues.apache.org/jira/browse/BEAM-8242 > Project: Beam > Issue Type: Bug > Components: sdk-go >Affects Versions: 2.15.0 > Environment: GNU/Linux >Reporter: Ian Lance Taylor >Assignee: Robert Burke >Priority: Major > Original Estimate: 0h > Time Spent: 1h > Remaining Estimate: 0h > > If a Go program is built with -buildmode=pie, the code that transfers an > unregistered function fails. It looks up the symbol in the symbol table, but > that is not the location of the function at execution time. This causes a > program crash when calling the function. > I have a patch for this problem that I will send shortly. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-8242) Go: unregistered Go functions fail when using -buildmode=pie
[ https://issues.apache.org/jira/browse/BEAM-8242?focusedWorklogId=314550=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-314550 ] ASF GitHub Bot logged work on BEAM-8242: Author: ASF GitHub Bot Created on: 18/Sep/19 18:30 Start Date: 18/Sep/19 18:30 Worklog Time Spent: 10m Work Description: lostluck commented on issue #9585: [BEAM-8242] Support -buildmode=pie with unregistered Go functions URL: https://github.com/apache/beam/pull/9585#issuecomment-532809867 Run Go Postcommit This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 314550) Time Spent: 50m (was: 40m) > Go: unregistered Go functions fail when using -buildmode=pie > > > Key: BEAM-8242 > URL: https://issues.apache.org/jira/browse/BEAM-8242 > Project: Beam > Issue Type: Bug > Components: sdk-go >Affects Versions: 2.15.0 > Environment: GNU/Linux >Reporter: Ian Lance Taylor >Assignee: Robert Burke >Priority: Major > Original Estimate: 0h > Time Spent: 50m > Remaining Estimate: 0h > > If a Go program is built with -buildmode=pie, the code that transfers an > unregistered function fails. It looks up the symbol in the symbol table, but > that is not the location of the function at execution time. This causes a > program crash when calling the function. > I have a patch for this problem that I will send shortly. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-8242) Go: unregistered Go functions fail when using -buildmode=pie
[ https://issues.apache.org/jira/browse/BEAM-8242?focusedWorklogId=314532=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-314532 ] ASF GitHub Bot logged work on BEAM-8242: Author: ASF GitHub Bot Created on: 18/Sep/19 17:59 Start Date: 18/Sep/19 17:59 Worklog Time Spent: 10m Work Description: wcn3 commented on pull request #9585: [BEAM-8242] Support -buildmode=pie with unregistered Go functions URL: https://github.com/apache/beam/pull/9585#discussion_r325815099 ## File path: sdks/go/pkg/beam/core/util/symtab/symtab_test.go ## @@ -0,0 +1,115 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +//http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package symtab + +import ( + "io/ioutil" + "os" + "os/exec" + "path/filepath" + "runtime" + "strings" + "testing" +) + +// TestSym2Addr builds and runs this test program. +const testprog = ` +package main + +import ( + "fmt" + "os" + "runtime" + + "github.com/apache/beam/sdks/go/pkg/beam/core/util/symtab" +) + +func die(format string, a ...interface{}) { + fmt.Fprintf(os.Stderr, format, a...) + os.Exit(1) +} + +func main() { + syms, err := symtab.New(os.Args[0]) + if err != nil { + die("%s: could not read symbols: %v", os.Args[0], err) + } + + symPC, err := syms.Sym2Addr("main.main") + if err != nil { + die("Sym2Addr(%q) failed: %v", "main.main", err) + } + + runtimePC := fnaddr() + if symPC != runtimePC { + die("PC from symbol table %x != runtime PC %x", symPC, runtimePC) + } +} + +// fnaddr returns the entry address of its caller. +func fnaddr() uintptr { + var pcs [2]uintptr + n := runtime.Callers(2, pcs[:]) + frames := runtime.CallersFrames(pcs[:n]) + frame, _ := frames.Next() + return frame.Func.Entry() +} +` + +func TestSym2Addr(t *testing.T) { + f, err := ioutil.TempFile("", "TestSym2Addr*.go") + if err != nil { + t.Fatal(err) + } + + fname := f.Name() + defer os.Remove(fname) + + if _, err := f.WriteString(testprog); err != nil { + t.Fatal(err) + } + if err := f.Close(); err != nil { + t.Fatal(err) + } + + bin := strings.TrimSuffix(fname, ".go") + defer os.Remove(bin) + + gotool := filepath.Join(runtime.GOROOT(), "bin", "go") + + for _, arg := range []string{"", "-buildmode=pie"} { Review comment: Perhaps it'd be good to explicitly test -buildmode=x where x is whatever the default is now. This way, if the default changed in the future to PIE, we'd have confidence we were testing the other relevant buildmode. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 314532) Time Spent: 40m (was: 0.5h) > Go: unregistered Go functions fail when using -buildmode=pie > > > Key: BEAM-8242 > URL: https://issues.apache.org/jira/browse/BEAM-8242 > Project: Beam > Issue Type: Bug > Components: sdk-go >Affects Versions: 2.15.0 > Environment: GNU/Linux >Reporter: Ian Lance Taylor >Priority: Major > Original Estimate: 0h > Time Spent: 40m > Remaining Estimate: 0h > > If a Go program is built with -buildmode=pie, the code that transfers an > unregistered function fails. It looks up the symbol in the symbol table, but > that is not the location of the function at execution time. This causes a > program crash when calling the function. > I have a patch for this problem that I will send shortly. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-8242) Go: unregistered Go functions fail when using -buildmode=pie
[ https://issues.apache.org/jira/browse/BEAM-8242?focusedWorklogId=314531=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-314531 ] ASF GitHub Bot logged work on BEAM-8242: Author: ASF GitHub Bot Created on: 18/Sep/19 17:58 Start Date: 18/Sep/19 17:58 Worklog Time Spent: 10m Work Description: wcn3 commented on issue #9585: [BEAM-8242] Support -buildmode=pie with unregistered Go functions URL: https://github.com/apache/beam/pull/9585#issuecomment-532796819 R @lostluck This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 314531) Time Spent: 0.5h (was: 20m) > Go: unregistered Go functions fail when using -buildmode=pie > > > Key: BEAM-8242 > URL: https://issues.apache.org/jira/browse/BEAM-8242 > Project: Beam > Issue Type: Bug > Components: sdk-go >Affects Versions: 2.15.0 > Environment: GNU/Linux >Reporter: Ian Lance Taylor >Priority: Major > Original Estimate: 0h > Time Spent: 0.5h > Remaining Estimate: 0h > > If a Go program is built with -buildmode=pie, the code that transfers an > unregistered function fails. It looks up the symbol in the symbol table, but > that is not the location of the function at execution time. This causes a > program crash when calling the function. > I have a patch for this problem that I will send shortly. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Work logged] (BEAM-8242) Go: unregistered Go functions fail when using -buildmode=pie
[ https://issues.apache.org/jira/browse/BEAM-8242?focusedWorklogId=313217=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-313217 ] ASF GitHub Bot logged work on BEAM-8242: Author: ASF GitHub Bot Created on: 16/Sep/19 17:50 Start Date: 16/Sep/19 17:50 Worklog Time Spent: 10m Work Description: ianlancetaylor commented on issue #9585: [BEAM-8242] Support -buildmode=pie with unregistered Go functions URL: https://github.com/apache/beam/pull/9585#issuecomment-531884946 R @wcn3 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 313217) Time Spent: 20m (was: 10m) > Go: unregistered Go functions fail when using -buildmode=pie > > > Key: BEAM-8242 > URL: https://issues.apache.org/jira/browse/BEAM-8242 > Project: Beam > Issue Type: Bug > Components: sdk-go >Affects Versions: 2.15.0 > Environment: GNU/Linux >Reporter: Ian Lance Taylor >Priority: Major > Original Estimate: 0h > Time Spent: 20m > Remaining Estimate: 0h > > If a Go program is built with -buildmode=pie, the code that transfers an > unregistered function fails. It looks up the symbol in the symbol table, but > that is not the location of the function at execution time. This causes a > program crash when calling the function. > I have a patch for this problem that I will send shortly. -- This message was sent by Atlassian Jira (v8.3.2#803003)
[jira] [Work logged] (BEAM-8242) Go: unregistered Go functions fail when using -buildmode=pie
[ https://issues.apache.org/jira/browse/BEAM-8242?focusedWorklogId=313215=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-313215 ] ASF GitHub Bot logged work on BEAM-8242: Author: ASF GitHub Bot Created on: 16/Sep/19 17:50 Start Date: 16/Sep/19 17:50 Worklog Time Spent: 10m Work Description: ianlancetaylor commented on pull request #9585: [BEAM-8242] Support -buildmode=pie with unregistered Go functions URL: https://github.com/apache/beam/pull/9585 When fetching function addresses from the symbol table, adjust them by the offset between the symbol table address and the execution address. Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily: - [ ] [**Choose reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) and mention them in a comment (`R: @username`). - [ ] Format the pull request title like `[BEAM-XXX] Fixes bug in ApproximateQuantiles`, where you replace `BEAM-XXX` with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue. - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). Post-Commit Tests Status (on master branch) Lang | SDK | Apex | Dataflow | Flink | Gearpump | Samza | Spark --- | --- | --- | --- | --- | --- | --- | --- Go | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Go/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Go/lastCompletedBuild/) | --- | --- | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Go_VR_Flink/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Go_VR_Flink/lastCompletedBuild/) | --- | --- | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Go_VR_Spark/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Go_VR_Spark/lastCompletedBuild/) Java | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Apex/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Apex/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink/lastCompletedBuild/)[![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Batch/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Batch/lastCompletedBuild/)[![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Streaming/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Streaming/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Gearpump/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Gearpump/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Samza/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Samza/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Spark/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Spark/lastCompletedBuild/)[![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Spark_Batch/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Spark_Batch/lastCompletedBuild/) Python | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Python2/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Python2/lastCompletedBuild/)[![Build Status](https://builds.apache.org/job/beam_PostCommit_Python35/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Python35/lastCompletedBuild/)[![Build Status](https://builds.apache.org/job/beam_PostCommit_Python36/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Python36/lastCompletedBuild/)[![Build