FAQ
Hello,

I'm writing a libuv binding library on Mac OS X using go version 1.1.1.
Unfortunately I'm getting a segmentation violation whenever my test
application imports the library and calls a C function to create a loop.
Both the library and test application compiles without errors. Any pointers
on how to resolve this issue is greatly appreciated.

Thanks,
Steven Ross
*
Library Code:*

package uv

/*
#include "libuv/include/uv.h"
#cgo LDFLAGS: -L./libuv -luv -framework CoreFoundation -framework
CoreServices
*/
import "C"

type Loop struct {
     t *C.uv_loop_t
}

func NewLoop() *Loop {
     return &Loop{C.uv_loop_new()}
}
*
Test Application Code:*

package main

import "uv"

func main() {
     _ = uv.NewLoop()
}

*Error:*

SIGSEGV: segmentation violation
PC=0x0
signal arrived during cgo execution

uv._Cfunc_uv_loop_new(0x2c280)
     uv/_obj/_cgo_defun.c:50 +0x2f
uv.NewLoop(0x206b)
     uv/_obj/_cgo_gotypes.go:398 +0x1c
main.main()
     /Users/steven/gocode/src/uv/tests/main.go:6 +0x1c

goroutine 2 [syscall]:

goroutine 3 [runnable]:
rax 0x1ed87
rbx 0x210f60
rcx 0x210f60
rdx 0x210ef8
rdi 0x210f60
rsi 0x56940
rbp 0x7fff5fbff9e0
rsp 0x7fff5fbff9c8
r8 0xc200038000
r9 0xc200038000
r10 0x3806794f
r11 0x206
r12 0x66481c43e99e
r13 0x664824582190
r14 0x130c9103944a8600
r15 0x0
rip 0x0
rflags 0x10202
cs 0x2b
fs 0x0
gs 0x0
exit status 2

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Steven Ross at Jul 3, 2013 at 10:52 am
    I know it's unlikely anyone will be able to help with this issue but
    thought it would be useful too add a little more info.

    The segmentation violation does not occur when using the exact same
    compiled libuv library from a C application. Also tried using
    runtime.LockOSThread().

    It's looking like a Go/cgo related issue. Thinking of reporting this as a
    bug if I'm able to convince myself Go is at fault.

    Thanks,
    Steven Ross

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Dave Cheney at Jul 3, 2013 at 10:53 am
    Tangential question: why do you want to use libuv inside Go ? The
    runtime already provides io capabilities that superior to evented io.
    On Wed, Jul 3, 2013 at 8:52 PM, Steven Ross wrote:
    I know it's unlikely anyone will be able to help with this issue but thought
    it would be useful too add a little more info.

    The segmentation violation does not occur when using the exact same compiled
    libuv library from a C application. Also tried using runtime.LockOSThread().

    It's looking like a Go/cgo related issue. Thinking of reporting this as a
    bug if I'm able to convince myself Go is at fault.

    Thanks,
    Steven Ross

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Steven Ross at Jul 3, 2013 at 11:01 am
    I wanted to create a socket library with some special capabilities that I
    wasn't able to accomplish using the net package. As this was for personal
    use, libuv seemed like a great library to deal with kqueue, epoll and iocp.
    On Wednesday, 3 July 2013 11:53:24 UTC+1, Dave Cheney wrote:

    Tangential question: why do you want to use libuv inside Go ? The
    runtime already provides io capabilities that superior to evented io.
    On Wed, Jul 3, 2013 at 8:52 PM, Steven Ross wrote:
    I know it's unlikely anyone will be able to help with this issue but thought
    it would be useful too add a little more info.

    The segmentation violation does not occur when using the exact same compiled
    libuv library from a C application. Also tried using
    runtime.LockOSThread().
    It's looking like a Go/cgo related issue. Thinking of reporting this as a
    bug if I'm able to convince myself Go is at fault.

    Thanks,
    Steven Ross

    --
    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...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Minux at Jul 3, 2013 at 10:59 am

    On Mon, Jul 1, 2013 at 9:25 AM, wrote:

    Hello,

    I'm writing a libuv binding library on Mac OS X using go version 1.1.1.
    Unfortunately I'm getting a segmentation violation whenever my test
    application imports the library and calls a C function to create a loop.
    Both the library and test application compiles without errors. Any pointers
    on how to resolve this issue is greatly appreciated.

    Thanks,
    Steven Ross
    *
    Library Code:*

    package uv

    /*
    #include "libuv/include/uv.h"
    #cgo LDFLAGS: -L./libuv -luv -framework CoreFoundation -framework
    CoreServices
    */
    import "C"

    type Loop struct {
    t *C.uv_loop_t
    }

    func NewLoop() *Loop {
    return &Loop{C.uv_loop_new()}
    }
    *
    Test Application Code:*

    package main

    import "uv"

    func main() {
    _ = uv.NewLoop()
    }

    *Error:*

    SIGSEGV: segmentation violation
    PC=0x0
    signal arrived during cgo execution

    uv._Cfunc_uv_loop_new(0x2c280)
    uv/_obj/_cgo_defun.c:50 +0x2f
    uv.NewLoop(0x206b)
    uv/_obj/_cgo_gotypes.go:398 +0x1c
    main.main()
    /Users/steven/gocode/src/uv/tests/main.go:6 +0x1c

    goroutine 2 [syscall]:

    goroutine 3 [runnable]:
    rax 0x1ed87
    rbx 0x210f60
    rcx 0x210f60
    rdx 0x210ef8
    rdi 0x210f60
    rsi 0x56940
    rbp 0x7fff5fbff9e0
    rsp 0x7fff5fbff9c8
    r8 0xc200038000
    r9 0xc200038000
    r10 0x3806794f
    r11 0x206
    r12 0x66481c43e99e
    r13 0x664824582190
    r14 0x130c9103944a8600
    r15 0x0
    rip 0x0
    rflags 0x10202
    cs 0x2b
    fs 0x0
    gs 0x0
    exit status 2
    if you compiled libuv yourselves, you could try using gdb to run the
    program as it can produce
    more useful information than Go's internal backtracer.

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJul 1, '13 at 6:11a
activeJul 3, '13 at 11:01a
posts5
users3
websitegolang.org

3 users in discussion

Steven Ross: 3 posts Dave Cheney: 1 post Minux: 1 post

People

Translate

site design / logo © 2022 Grokbase