Skip to content
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

Failed building obfuscated binary that uses github.com/gogo/protobuf/proto #723

Closed
arhim-bruje122 opened this issue Apr 30, 2023 · 3 comments

Comments

@arhim-bruje122
Copy link

arhim-bruje122 commented Apr 30, 2023

What version of Garble and Go are you using?

$ garble version
mvdan.cc/garble v0.9.3
$ go version
go version go1.20.3 darwin/arm64

What environment are you running Garble on?

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/x/Library/Caches/go-build"
GOENV="/Users/x/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/x/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/x/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.20.3/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.20.3/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.3"
GCCGO="gccgo"
AR="ar"
CC="cc"
CXX="c++"
CGO_ENABLED="1"
GOMOD="/Users/x/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/j2/gjnvkvrd72n08y5jtl_x5wjm0000gn/T/go-build3956090031=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

built application using using garble.

code sample to reproduce the error

package main

import (
    "fmt"
    "github.com/gogo/protobuf/proto"
)

func main() {
    // Define a message
    message := &MyMessage{
        Foo: proto.String("Hello"),
        Bar: proto.Int32(42),
    }

    // Serialize the message to bytes
    data, err := proto.Marshal(message)
    if err != nil {
        panic(err)
    }

    // Deserialize the message from bytes
    newMessage := &MyMessage{}
    err = proto.Unmarshal(data, newMessage)
    if err != nil {
        panic(err)
    }

    // Print the message contents
    fmt.Println(*newMessage.Foo)
    fmt.Println(*newMessage.Bar)
}

// Define a protobuf message
type MyMessage struct {
    proto.Message // Embed the proto.Message interface
    Foo *string `protobuf:"bytes,1,opt,name=foo" json:"foo,omitempty"`
    Bar *int32  `protobuf:"varint,2,opt,name=bar" json:"bar,omitempty"`
}


Command that was used for building the code:
GOGARBLE=github.com,gopkg.in CGO_ENABLED=0 garble -tiny -literals -seed=000000000000000000 build

What did you expect to see?

Successfully built binary.

What did you see instead?

# github.com/gogo/protobuf/proto
:1: cannot use new(struct{cTbFKPsI sync.Mutex; hHZQMchMkm9 map[int32]Extension}) (value of type *struct{cTbFKPsI sync.Mutex; hHZQMchMkm9 map[int32]Extension}) as *struct{mu sync.Mutex; extensionMap map[int32]Extension} value in assignment
:1: cannot use new(struct{cTbFKPsI sync.Mutex; hHZQMchMkm9 map[int32]Extension}) (value of type *struct{cTbFKPsI sync.Mutex; hHZQMchMkm9 map[int32]Extension}) as *struct{mu sync.Mutex; extensionMap map[int32]Extension} value in struct literal
exit status 2
exit status 1
@mvdan
Copy link
Member

mvdan commented Apr 30, 2023

See #685.

@mvdan mvdan closed this as not planned Won't fix, can't repro, duplicate, stale Apr 30, 2023
@arhim-bruje122
Copy link
Author

Will the problem be fixed?

@mvdan
Copy link
Member

mvdan commented Apr 30, 2023

The issue is open. There is a workaround via GOGARBLE in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants