tinyzimmer / go-gst

Gstreamer bindings and utilities for golang
GNU Lesser General Public License v2.1
130 stars 37 forks source link

panic: runtime error: invalid memory address or nil pointer dereference #61

Open hly0025 opened 1 year ago

hly0025 commented 1 year ago

I'm getting a runtime error for an invalid memory address.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x5d1e74]

goroutine 191 [running]:
github.com/tinyzimmer/go-gst/gst.(*Sample).Instance.func1(0xc001265ca0?)
    /go/pkg/mod/github.com/tinyzimmer/go-gst@v0.2.33/gst/gst_sample.go:34 +0x14
github.com/tinyzimmer/go-gst/gst.(*Sample).Instance(0x7f5b6804d350?)
    /go/pkg/mod/github.com/tinyzimmer/go-gst@v0.2.33/gst/gst_sample.go:34 +0x19
github.com/tinyzimmer/go-gst/gst.(*Sample).GetCaps.func1(0xc001265ec0?)
    /go/pkg/mod/github.com/tinyzimmer/go-gst@v0.2.33/gst/gst_sample.go:60 +0x19
github.com/tinyzimmer/go-gst/gst.(*Sample).GetCaps(0x4b78a5?)
    /go/pkg/mod/github.com/tinyzimmer/go-gst@v0.2.33/gst/gst_sample.go:60 +0x19

Looking into gst_sample.go line 34 and 60 is:

Line 34 here: // Instance returns the underlying *GstSample instance. func (s *Sample) Instance() *C.GstSample { return C.toGstSample(unsafe.Pointer(s.sample)) }

Line 60 here: // GetCaps returns the caps associated with this sample. Take a ref if you need to hold on to them // longer then the life of the sample. func (s *Sample) GetCaps() *Caps { return FromGstCapsUnsafeNone(unsafe.Pointer(C.gst_sample_get_caps(s.Instance()))) }

How is it possible that the line 34 and 60 is causing this? I haven't found a way to replicate it, but this happens after running my application after a few hours consistently.

I believe the lines of code that may cause the above is as follows:

    go_sample := sink.PullSample() 
    go_caps_format := my_sample.GetCaps().GetStructureAt(0)
RSWilli commented 1 year ago

@hly0025 move this issue to https://github.com/go-gst/go-gst (where future development of the bindings will take place) if you think it is necessary.