I'm building a .so on linux (64bit ubuntu) that is used in a closed-source 
application. Build steps:

go build -buildmode=c-archive gfeeder.go
cc -c  -fPIC -pthread cfeeder.c
cc -c -fPIC -pthread feeder.c
ld -shared -o feeder.so feeder.o cfeeder.o gfeeder.a

$ cat gfeeder.go
package main

import (
    "C"
)

//export AddInt
func AddInt(x int) int {
    return x + 4
}

func main() {}


$ cat feeder.c

typedef long long GoInt64;
typedef GoInt64 GoInt;
extern GoInt AddInt(GoInt p0);

long feed(long y) {
    long z;
    z = AddInt(y);
    return z;
}

When I run the proprietary application with my .so it segfaults at the very 
end of the process. If I put a sleep() call in feeder.c after the AddInt 
call, the process exits gracefully.

My intuition tells me it's some kind of pthread issue (or something else in 
the golang runtime). Is there some kind of clean up function I can call for 
the golang runtime? Or maybe some kind of pthread wait/join I can use? The 
example code I found for pthread join requires thread ids. I don't know how 
to get those from the golang runtime.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to