Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segfault in (*Message).ParseError #5

Open
felixb opened this issue Dec 6, 2014 · 0 comments
Open

segfault in (*Message).ParseError #5

felixb opened this issue Dec 6, 2014 · 0 comments

Comments

@felixb
Copy link

felixb commented Dec 6, 2014

I get a segfault when trying to parse a error message from gstreamer.

*** glibc detected *** /usr/local/bin/rtp-receiver: free(): invalid pointer: 0x00fd9040 ***
SIGABRT: abort
PC=0xb6c1acdc

goroutine 43 [syscall]:
runtime.cgocall(0xf7f8, 0x8246cb88)
    /usr/lib/go/src/pkg/runtime/cgocall.c:142 +0xdc fp=0x8246cb78 sp=0x8246cb4c
github.com/ziutek/gst._Cfunc_free(0xfd9040)
    github.com/ziutek/gst/_obj/_cgo_defun.c:82 +0x34 fp=0x8246cb84 sp=0x8246cb78
github.com/ziutek/gst.(*Message).ParseError(0x10b9c08, 0x96b92bc0, 0x96b2c680, 0x73)
    /home/pi/.go/src/github.com/ziutek/gst/message.go:157 +0x188 fp=0x8246cba8 sp=0x8246cb84
main.(*Manager).onMessage(0x96b00540, 0x96b0b7a8, 0x10b9c08)
    /home/pi/go/streaming/common-client.go:49 +0xd0 fp=0x8246cc1c sp=0x8246c
[..]

I tried it with different go versions without any change in behavior.

My current workaround is to comment out two lines in the library to not make it free the two pointers:

func (m *Message) ParseError() (err *glib.Error, debug string) {
        var d *C.gchar
        var     e, ret_e *C.GError

        C.gst_message_parse_error(m.g(), &e, &d)
        // prevent segfaults by not freeing the pointer
        //defer C.free(unsafe.Pointer(e))
        //defer C.free(unsafe.Pointer(d))

        debug = C.GoString((*C.char)(d))
        ret_e = new(C.GError)
        *ret_e = *e
        err = (*glib.Error)(unsafe.Pointer(ret_e))
        return
}

I'm not sure, if this is the way to fix it. I guess it creates a memory leak.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant