seccomp / libseccomp-golang

The libseccomp golang bindings repository
BSD 2-Clause "Simplified" License
268 stars 56 forks source link

BUG: mismatched types C.uint32_t and C.uint on older gcc versions #2

Closed meihuabo closed 7 years ago

meihuabo commented 9 years ago
root@meihuabo:~/goWorkspace/src/github.com/seccomp/libseccomp-golang# go install 
# github.com/seccomp/libseccomp-golang
./seccomp_internal.go:298: invalid operation: in.toNative() == *_Cvar_C_ARCH_BAD (mismatched types C.uint32_t and C.uint)
./seccomp_internal.go:328: invalid case *_Cvar_C_ARCH_X86 in switch on a (mismatched types C.uint and C.uint32_t)
./seccomp_internal.go:330: invalid case *_Cvar_C_ARCH_X86_64 in switch on a (mismatched types C.uint and C.uint32_t)
./seccomp_internal.go:332: invalid case *_Cvar_C_ARCH_X32 in switch on a (mismatched types C.uint and C.uint32_t)
./seccomp_internal.go:334: invalid case *_Cvar_C_ARCH_ARM in switch on a (mismatched types C.uint and C.uint32_t)
./seccomp_internal.go:336: invalid case *_Cvar_C_ARCH_NATIVE in switch on a (mismatched types C.uint and C.uint32_t)
./seccomp_internal.go:338: invalid case *_Cvar_C_ARCH_AARCH64 in switch on a (mismatched types C.uint and C.uint32_t)
root@AY14052923334089220fZ:/mydata/goWorkspace/gotest/src/github.com/seccomp/libseccomp-golang# nt and C.uint32_t)

server info:

Ubuntu 12.04.5 LTS \n \l

Linux meihuabo 3.8.0-44-generic #66~precise1-Ubuntu SMP Tue Jul 15 04:01:04 

go version go1.4.1    linux/amd64

issue in runc mismatched types C.uint32_t and C.uint

meihuabo commented 9 years ago
package main

import (
    "fmt"
    "reflect"
)

/*
#include <stdlib.h>
#include <seccomp.h>
#define ARCH_BAD ~0
const uint32_t C_ARCH_BAD = ARCH_BAD;
*/
import "C"

func main() {
    fmt.Println(reflect.TypeOf(C.C_ARCH_BAD))
}

i run this code on different server and get different result:

result1:               main._Ctype_uint32_t
result1:               main._Ctype_uint
meihuabo commented 9 years ago

resolve it: https://github.com/golang/go/issues/12599 my C complier gcc(4.6.3) is too old

mheon commented 9 years ago

Glad to hear this was resolved - I was having difficulty replicating the failure. Probably worth adding something to the readme about GCC and Golang versions that we can build against.

pcmoore commented 9 years ago

I'm going to reopen this so we don't forget it, I agree with @mheon that we should document our version dependencies. @mheon or @meihuabo, do either of you want to draft patch for the readme?

meihuabo commented 9 years ago

I also agree with @mheon I will try different gcc and go combination to find the minimum version to install libseccomp-golang

pcmoore commented 9 years ago

Great, thanks for the help!

mheon commented 9 years ago

The earliest version I've personally verified on is Ubuntu 14.04's Golang 1.2.1 and GCC 4.8.4. GCC <= 4.6 seems to cause the issue indicated here. Would be interesting to see if GCC 4.7.x works.

meihuabo commented 9 years ago

I've verified GCC 4.6.4 and it works But I encountered som difficulties when setting up to GCC 4.6.x environment still working on the environment

thorduri commented 7 years ago

Would a blurb like the following (on top of #14 -- I'm loathe to add it directly now) suffice to close this issue ?

* Installing the package

Using go get:

    $ go get github.com/seccomp/libseccomp-golang

For golang versions older then 1.2.1, and GCC versions older then 4.8.4 your milage may vary.

Adding a "supported" blurb is harder, as there are currently no tests for that (yet).

pcmoore commented 7 years ago

@mheon what do you think of @thorduri's suggestion?

mheon commented 7 years ago

@pcmoore Sounds fine here. I don't anticipate many people still on this combination, as even LTS distros like Debian and RHEL have moved past Go 1.2, but it's good to cover our bases.

thorduri commented 7 years ago

@mheon It has probably less to do with the go version, then the packaged / distributed libseccomp though.

I'll submit a PR with that blurb when #14 gets merged.

I'd love to see the PRs/Issues that are attached to the v2.3 milestone dealt with, and then see #4 implemented -- and maintaining "tagging" parity with libseccomp (I have a similar peeve with vendoring the package).

Anything I can do specifically to help with that ?

pcmoore commented 7 years ago

@thorduri I apologize that I'm not clearing the libseccomp issues/PRs very quickly, especially when it comes to the golang bindings. I'm hopeful that I will be able to spend more time on these as we get close to the end of the year, but at the moment the audit and SELinux kernel work is dominating my time.

Thanks for your interest and patches, I really do appreciate the help!

thorduri commented 7 years ago

@pcmoore No problem!

pcmoore commented 7 years ago

@thorduri I hope you don't mind, I went ahead and added some text to the README via ab55783446ad1ca5c740040f73ee629fe113521e, does this look okay to you?

pcmoore commented 7 years ago

Based on the thumbs-up, I'm going to consider this resolved and close this issue. Thanks all!