Comments (7)
Actually, it looks like in this case the RegisterPIndexImplType.Open
function is returning nil, nil, nil
. If OTOH it returns nil, nil, err
then there is no panic.
from cbgt.
I guess I should probably post which CBGT commit I'm using, eh?
Looks like it's a fairly old commit: 7e6a6dc
I will see if I can reproduce on the current master branch.
from cbgt.
Reproduced on CBGT commit 17117fb
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x48 pc=0x41be42e]
goroutine 123 [running]:
github.com/couchbase/cbgt.(*DCPFeed).GetMetaData.func1(0x0, 0x0)
/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/cbgt/feed_dcp.go:477 +0x12e
github.com/couchbase/cbgt.Timer.func1()
/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/cbgt/misc.go:234 +0x25
github.com/rcrowley/go-metrics.(*StandardTimer).Time(0xc8205bc7b0, 0xc820440e60)
/Users/tleyden/Development/sync_gateway/src/github.com/rcrowley/go-metrics/timer.go:212 +0x3d
github.com/couchbase/cbgt.Timer(0xc820518f00, 0x52a97a8, 0xc8205bc7b0, 0x0, 0x0)
/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/cbgt/misc.go:235 +0xa7
github.com/couchbase/cbgt.(*DCPFeed).GetMetaData(0xc820074270, 0x2d, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/cbgt/feed_dcp.go:480 +0x123
github.com/couchbase/go-couchbase/cbdatasource.(*bucketDataSource).getVBucketMetaData(0xc820620900, 0x2d, 0x60, 0x4878dc0, 0x0, 0x0)
/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:1235 +0xa2
github.com/couchbase/go-couchbase/cbdatasource.(*bucketDataSource).sendStreamReq(0xc820620900, 0xc8203647e0, 0x2d, 0x0, 0x0)
/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:1275 +0x53
github.com/couchbase/go-couchbase/cbdatasource.(*bucketDataSource).refreshWorker(0xc820620900, 0xc8203647e0, 0xc820518d80, 0xc8200a6580, 0x40, 0x40, 0x0, 0x0)
/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:1011 +0x84e
github.com/couchbase/go-couchbase/cbdatasource.(*bucketDataSource).worker(0xc820620900, 0xc820414ba0, 0xf, 0xc82016d1a0, 0x0)
/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:957 +0x11ea
github.com/couchbase/go-couchbase/cbdatasource.(*bucketDataSource).workerStart.func1.1(0x2)
/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:681 +0x48
github.com/couchbase/go-couchbase/cbdatasource.ExponentialBackoffLoop(0xc8205bd2c0, 0x23, 0xc820591f38, 0x64, 0x3fc00000, 0x7d0)
/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:1518 +0x2b
github.com/couchbase/go-couchbase/cbdatasource.(*bucketDataSource).workerStart.func1(0xc820620900, 0xc820414ba0, 0xf, 0xc82016d1a0, 0x64, 0xc83fc00000, 0x7d0)
/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:682 +0x112
created by github.com/couchbase/go-couchbase/cbdatasource.(*bucketDataSource).workerStart
/Users/tleyden/Development/sync_gateway/src/github.com/couchbase/go-couchbase/cbdatasource/cbdatasource.go:685 +0xb7
from cbgt.
Yep, I agree libraries shouldn't panic, and in this case cbgt is not invoking panic(), but it's a nil pointer dereference.
The feed_dcp line 477 is ...
value, lastSeq, err = dest.OpaqueGet(partition)
So, that means dest is nil.
From tracing the code paths, dest can be nil if the pindex implementation returns a nil for the Dest return value in the New or Open callbacks...
https://github.com/couchbase/cbgt/blob/master/pindex_impl.go#L39
https://github.com/couchbase/cbgt/blob/master/pindex_impl.go#L45
New func(indexType, indexParams, path string, restart func()) (
PIndexImpl, Dest, error)
Open func(indexType, path string, restart func()) (
PIndexImpl, Dest, error)
So, @tleyden, wondering if there are any codepaths in sync-gateway's pindex New/Open callbacks that might return a nil Dest and nil error?
from cbgt.
Yeah, it was only a codepath that came up while doing some intermediate changes, but it was returning a nil dest and a nil error.
from cbgt.
Thanks - I'm going to close this as won't fix, then, on the hope that the elite corps who implement new PIndex types (*) always return a non-nil Dest when nil error.
(*) - same folks deserve to receive "PIndex" or "cbgt" t-shirt. :-)
from cbgt.
What about detecting this situation and doing an explicit panic?
The value add is that instead of the meaningless error:
panic: runtime error: invalid memory address or nil pointer dereference
you could return:
panic: runtime error: you returned a nil Dest and nil error, and that's just something I can't deal with
from cbgt.
Related Issues (12)
- add docs/instructions on open-source contributing changes and CLA
- Diag should include write counters
- TestManagerRestart manager_test.go:199 unit test failure HOT 1
- Remove random seed initializer
- release instructions in Makefile are out of date
- Panic when hitting diag endpoint
- Make CBGT UI more "embeddable" HOT 2
- readme UI screenshots link broken
- cannot search code because repo is a fork
- monitor.js still refers to bleve
- Content-type is not application/json for cbgt diagnostics HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cbgt.