[ 
https://issues.apache.org/jira/browse/BEAM-7994?focusedWorklogId=296673&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-296673
 ]

ASF GitHub Bot logged work on BEAM-7994:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 17/Aug/19 00:04
            Start Date: 17/Aug/19 00:04
    Worklog Time Spent: 10m 
      Work Description: wcn3 commented on pull request #9362: [BEAM-7994] 
Fixing unsafe pointer usage for Go 1.13
URL: https://github.com/apache/beam/pull/9362#discussion_r314923396
 
 

 ##########
 File path: sdks/go/pkg/beam/core/util/reflectx/functions.go
 ##########
 @@ -40,6 +40,8 @@ func FunctionName(fn interface{}) string {
 // points to a valid function implementation.
 func LoadFunction(ptr uintptr, t reflect.Type) interface{} {
        v := reflect.New(t).Elem()
-       *(*uintptr)(unsafe.Pointer(v.Addr().Pointer())) = 
(uintptr)(unsafe.Pointer(&ptr))
+       p := new(uintptr)
+       *p = ptr
+       *(*unsafe.Pointer)(unsafe.Pointer(v.Addr().Pointer())) = 
unsafe.Pointer(p)
 
 Review comment:
   The problem was that the original code relies on the behavior that when &ptr 
is evaluated, the resulting anonymous value will be on the heap. The new 
compiler is able to not put it on the heap, and does so, which causes this code 
to crash in Go 1.13.
   
   This change makes the expected behavior explicit by allocating p on the heap 
and then assigning it's pointed-to value to ptr, thus p == &ptr and the 
remaining code works as before.
   
   The unit test exercises this function. I verified that the old code crashed 
under Go 1.13 (worked in Go 1.12) and the new code works in both versions.
   
 
----------------------------------------------------------------
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:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 296673)
    Time Spent: 1h 40m  (was: 1.5h)

> BEAM SDK has compatibility problems with go1.13
> -----------------------------------------------
>
>                 Key: BEAM-7994
>                 URL: https://issues.apache.org/jira/browse/BEAM-7994
>             Project: Beam
>          Issue Type: Improvement
>          Components: sdk-go
>            Reporter: Bill Neubauer
>            Assignee: Bill Neubauer
>            Priority: Minor
>          Time Spent: 1h 40m
>  Remaining Estimate: 0h
>
> The Go team identified a problem in the Beam SDK that appears due to runtime 
> changes in Go 1.13, which is upcoming. There is a backwards compatible fix 
> the team recommended.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to