Uploaded image for project: 'Couchbase Go SDK'
  1. Couchbase Go SDK
  2. GOCBC-795

gocbcore segmentation fault when trying to cancel an operation

    XMLWordPrintable

Details

    • Bug
    • Resolution: User Error
    • Major
    • 2.0.1
    • 2.0.0
    • library
    • None

    Description

      While debugging an issue with cbbackupmgr (MB-37869) I managed to get a segmentation fault while canceling a set with meta operation. Below I've provided the stack trace which shows that I got a nil pointer dereference on the mutex lock. For me to call 'Cancel' on the operation it mustn't have been nil at the time (in backup).

      panic: runtime error: invalid memory address or nil pointer dereference                                                                                        
      [signal SIGSEGV: segmentation violation code=0x1 addr=0xbc pc=0x78306d]                                                                                        
                                                                                                                                                                     
      goroutine 82 [running]:                                                                                                                                        
      sync.(*Mutex).Lock(...)                                                                                                                                        
              /usr/lib/go/src/sync/mutex.go:74                                                                                                                       
      github.com/couchbase/gocbcore%2ev8.(*memdQRequest).Cancel(0x0, 0xc000269dd0)                                                                                   
              /home/james/Projects/couchbase-build/godeps/src/github.com/couchbase/gocbcore.v8/memdqpackets.go:103 +0x2d                                             
      github.com/couchbase/backup/couchbase.(*operation).complete(0xc00066c780, 0x0, 0x0)                                                                            
              /home/james/Projects/couchbase-build/goproj/src/github.com/couchbase/backup/couchbase/operation.go:113 +0xca                                           
      github.com/couchbase/backup/couchbase.(*SetWithMeta).callback(...)                                                                                             
              /home/james/Projects/couchbase-build/goproj/src/github.com/couchbase/backup/couchbase/operation.go:240                                                 
      github.com/couchbase/gocbcore%2ev8.(*Agent).SetMetaEx.func1(0xc00053d0e0, 0xc00066c870, 0x0, 0x0)                                                              
              /home/james/Projects/couchbase-build/godeps/src/github.com/couchbase/gocbcore.v8/agentops_internal.go:121 +0xd7                                        
      github.com/couchbase/gocbcore%2ev8.(*memdQRequest).tryCallback(0xc00066c870, 0xc00053d0e0, 0x0, 0x0, 0xc0005616a0)                                             
              /home/james/Projects/couchbase-build/godeps/src/github.com/couchbase/gocbcore.v8/memdqpackets.go:90 +0xbc                                              
      github.com/couchbase/gocbcore%2ev8.(*memdClient).resolveRequest(0xc0000b5220, 0xc00053d0e0)                                                                    
              /home/james/Projects/couchbase-build/godeps/src/github.com/couchbase/gocbcore.v8/memdclient.go:241 +0x2ae                                              
      github.com/couchbase/gocbcore%2ev8.(*memdClient).run.func2(0xc0000b5220, 0xc00002c840, 0xc00002c900, 0xc00002c960)                                             
              /home/james/Projects/couchbase-build/godeps/src/github.com/couchbase/gocbcore.v8/memdclient.go:345 +0x295                                              
      created by github.com/couchbase/gocbcore%2ev8.(*memdClient).run                                                                                                
              /home/james/Projects/couchbase-build/godeps/src/github.com/couchbase/gocbcore.v8/memdclient.go:272 +0x105
      

      Expected results:

      If a user calls 'Cancel' on an inflight operation (at the time a non nil pointer) it should return whether or not the operation succeeds (e.g. it shouldn't panic).

      Actual results:

      Got a nil pointer dereference when trying to aquire exclusive access to the 'memdQRequest'

      Version:

      gocbcore.v8 - '63dd10dcba15d5d9253774df778d36635c337b67'

      I understand that this is a slightly older version of gocbcore, however, I've look at the code in master (although in a different location) it appears that this panic would still be possible.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              charles.dixon Charles Dixon
              james.lee James Lee
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty