Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-151309

Linker collision when using libnd cgo bindings with libvirt-go

Linking RHIVOS CVEs to...Migration: Automation ...Sync from "Extern...XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Undefined Undefined
    • None
    • CentOS Stream 9
    • libnbd
    • None
    • None
    • None
    • rhel-virt-tools
    • None
    • False
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None
    • None
    • Unspecified
    • Unspecified
    • Unspecified
    • All
    • None

      What were you trying to do that didn't work?

      CNV currently compiles some of its components with libvirt cgo bindings which features an exported function with the name `freeCallbackId`[1]. Recently, we tried adding libnbd. In callbacks.go, libnbd exports a function with the same exact name as the aforementioned libvirt function[2] and because C relies on a global namespace, the system linker panics when it tries to link our binary that contains both.

       [1]https://gitlab.com/libvirt/libvirt-go-module/-/blob/master/callbacks.go#L74
       [2]https://gitlab.com/nbdkit/libnbd/-/blob/master/golang/callbacks.go#L74

      What is the impact of this issue to you?

      Can't compile a binary using both libvirt and libnbd cgo bindings.

      Please provide the package NVR for which the bug is seen:

      How reproducible is this bug?:

      Steps to reproduce

      https://github.com/kubevirt/kubevirt/pull/16883 - currently uses a workaround by replacing all freeCallbackId occurrences in the vendored libnbd package.

      Expected results

      Can compile with both libvirt and libnbd cgo bindings.

      Actual results

      14:02:14: /usr/bin/ld: /tmp/go-link-2658898137/000079.o: in function `freeCallbackId':
      14:02:14: _cgo_export.c:(.text+0x0): multiple definition of `freeCallbackId'; /tmp/go-link-2658898137/000023.o:_cgo_export.c:(.text+0x87): first defined here
      14:02:14: collect2: error: ld returned 1 exit status 

              rhn-eng-rjones Richard Jones
              rh-ee-aaloni Adi Aloni
              virt-maint virt-maint
              Ganesh Hubale Ganesh Hubale
              Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

                Created:
                Updated:
                Resolved: