confluentinc / confluent-kafka-go

Confluent's Apache Kafka Golang client
Apache License 2.0
4.59k stars 652 forks source link

Build and run binary return code 137 #1161

Open theaveasso opened 5 months ago

theaveasso commented 5 months ago

Description

I want to start testing kafka producer but always fail to run from binary when I adding this package. If I run it using go run . it works perfectly fine.

Here is my code

func main() {
    producer, err := kafka.NewProducer(&kafka.ConfigMap{
        "bootstrap.servers": "localhost:29092",
    })
    if err != nil {
        log.Println(err)
    }
    fmt.Println("hello world")

    defer producer.Close()
}
/bin/sh: line 1: 55716 Killed: 9
Error: Producer process terminated with code 137

How to reproduce

  1. Create a simple main.go
  2. Create a new Producer

    func main() {
    producer, err := kafka.NewProducer(&kafka.ConfigMap{
        "bootstrap.servers": "localhost:29092",
    })
    if err != nil {
        log.Println(err)
    }
    fmt.Println("hello world")
    
    defer producer.Close()
    }
  3. Run build
    go build -o ./bin/producer ./main.go
    ./bin/producer

Checklist

Please provide the following information:

milindl commented 5 months ago

Seems similar to #1092. It seems to be a macOS specific thing (code 137 is SIGKILL). It seems to be a consequence of the binary being unsigned... Something like in this issues https://github.com/golang/go/issues/63997#issuecomment-1801342180 (not the exact same thing, but something similar). There are a lot of issues around macOS arm64 requiring a signed binary.

I can suggest to try signing the binary manually as described in the ticket above^.

Other way might be to try something as given on this page: https://github.molgen.mpg.de/pages/bs/macOSnotes/mac/mac_procs_unsigned.html

I could not try either of these methods since I'm using a Linux machine. If either of those works for you, please let me know so I will update the READMEs to highlight this particular issue.

theaveasso commented 5 months ago

@milindl I have tried, but still the same error.

spctl --add ./bin/producer
milindl commented 5 months ago

What about the codesign method shown in the github comment?

Also could you check /var/log/system.log after the kill of the application? It might contain some more useful hints for us.