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

SIKFromAddress data race #1197

Closed
p4u opened this issue Nov 23, 2023 · 0 comments · Fixed by #1199
Closed

SIKFromAddress data race #1197

p4u opened this issue Nov 23, 2023 · 0 comments · Fixed by #1199
Assignees

Comments

@p4u
Copy link
Member

p4u commented Nov 23, 2023

Looks like there is a data race, probably the SIK tree is updated while, at the same time, a Get operation is performed.
When the tree is updated, the nodes on the tree change and those that are no longer required, are removed. If a Get operation is in course, it will fail at some point because some nodes of the Path do not exist anymore.

2023-11-22T14:00:34.636Z DBG middleware/logger.go:158 > "GET https://api-dev.vocdoni.net:443/metrics HTTP/2.0" from 95.217.216.185:54082 - 200 21252B in 14.135206ms
2023-11-22T14:00:43.088Z INF ipfs storage addresses=26934 peers=405 pins=2289
2023-11-22T14:00:43.81Z INF offchain downloader enqueued=0 retrying=0 total=447
2023-11-22T14:00:49.977Z INF vochain status blockTime="1m:10.00 10m:10.34 1h:10.40 6h:10.40 24h:10.40" elections=579 height=110053 mempool=0 peers=4 voteCache=0 votes=4883 votes/min=0
2023-11-22T14:00:50.702Z INF subpub network cluster=1 known=26957 peers=213
2023-11-22T14:00:51.371Z DBG ipfs/ipfs.go:314 > retrieved file /ipfs/bafybeigwsmihkf7krxkfuqejflfrao43g3ortsw4i6r6ouyzljp7mlci4e from cache
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x98 pc=0x2f38533]

goroutine 125009948 [running]:
github.com/cockroachdb/pebble.(*Batch).Get(0xc0175f2a48?, {0xc01d15ae10?, 0x0?, 0x0?})
	github.com/cockroachdb/[email protected]/batch.go:550 +0x13
go.vocdoni.io/dvote/db/pebbledb.get({0x4507ea0?, 0x0?}, {0xc01d15ae10?, 0x366d320?, 0x1?})
	go.vocdoni.io/dvote/db/pebbledb/pebledb.go:21 +0x33
go.vocdoni.io/dvote/db/pebbledb.(*WriteTx).Get(0x0?, {0xc01d15ae10?, 0x0?, 0x0?})
	go.vocdoni.io/dvote/db/pebbledb/pebledb.go:69 +0x2e
go.vocdoni.io/dvote/db/prefixeddb.(*PrefixedWriteTx).Get(0xc02635d4a0, {0xc00b77df12, 0x20, 0x0?})
	go.vocdoni.io/dvote/db/prefixeddb/prefixeddb.go:117 +0x10c
go.vocdoni.io/dvote/tree/arbo.(*Tree).down(0xc00f5358c0, {0x7f7f64cee2f8, 0xc02635d4a0}, {0xc015c6a330, 0x14, 0x14}, {0xc00b77df12, 0x20, 0x20}, {0xc016896c00, ...}, ...)
	go.vocdoni.io/dvote/tree/arbo/navigate.go:24 +0xee
go.vocdoni.io/dvote/tree/arbo.(*Tree).down(0xc00f5358c0, {0x7f7f64cee2f8, 0xc02635d4a0}, {0xc015c6a330, 0x14, 0x14}, {0xc00b77dea2, 0x20, 0x40}, {0xc016896c00, ...}, ...)
	go.vocdoni.io/dvote/tree/arbo/navigate.go:77 +0x851
go.vocdoni.io/dvote/tree/arbo.(*Tree).down(0xc00f5358c0, {0x7f7f64cee2f8, 0xc02635d4a0}, {0xc015c6a330, 0x14, 0x14}, {0xc00b77de72, 0x20, 0x20}, {0xc01f150ea0, ...}, ...)
	go.vocdoni.io/dvote/tree/arbo/navigate.go:82 +0xaaf
go.vocdoni.io/dvote/tree/arbo.(*Tree).down(0xc00f5358c0, {0x7f7f64cee2f8, 0xc02635d4a0}, {0xc015c6a330, 0x14, 0x14}, {0xc00b77ddd2, 0x20, 0x20}, {0xc01f150ea0, ...}, ...)
	go.vocdoni.io/dvote/tree/arbo/navigate.go:77 +0x851
go.vocdoni.io/dvote/tree/arbo.(*Tree).down(0xc00f5358c0, {0x7f7f64cee2f8, 0xc02635d4a0}, {0xc015c6a330, 0x14, 0x14}, {0xc00b77dd82, 0x20, 0x20}, {0xc00316c2a0, ...}, ...)
	go.vocdoni.io/dvote/tree/arbo/navigate.go:77 +0x851
go.vocdoni.io/dvote/tree/arbo.(*Tree).down(0xc00f5358c0, {0x7f7f64cee2f8, 0xc02635d4a0}, {0xc015c6a330, 0x14, 0x14}, {0xc00b77dd12, 0x20, 0x40}, {0xc02040d008, ...}, ...)
	go.vocdoni.io/dvote/tree/arbo/navigate.go:77 +0x851
go.vocdoni.io/dvote/tree/arbo.(*Tree).down(0xc00f5358c0, {0x7f7f64cee2f8, 0xc02635d4a0}, {0xc015c6a330, 0x14, 0x14}, {0xc016135f60, 0x20, 0x20}, {0x0, ...}, ...)
	go.vocdoni.io/dvote/tree/arbo/navigate.go:82 +0xaaf
go.vocdoni.io/dvote/tree/arbo.(*Tree).GetWithTx(0xc00f5358c0, {0x7f7f64cee2f8, 0xc02635d4a0}, {0xc015c6a330, 0x14, 0x14})
	go.vocdoni.io/dvote/tree/arbo/tree.go:541 +0x453
go.vocdoni.io/dvote/tree.(*Tree).Get(0x13c2e1d?, {0x7f7f64cee2f8?, 0xc02635d4a0?}, {0xc015c6a330?, 0x36cdd40?, 0x1c000230638?})
	go.vocdoni.io/dvote/tree/tree.go:70 +0x77
go.vocdoni.io/dvote/statedb.(*TreeUpdate).Get(...)
	go.vocdoni.io/dvote/statedb/treeupdate.go:63
go.vocdoni.io/dvote/statedb.(*TreeUpdate).DeepGet(0xc00316c000?, {0xc015c6a330, 0x14, 0x14}, {0xc00316c000?, 0x36cdd40?, 0xc00066a601?})
	go.vocdoni.io/dvote/statedb/treeupdate.go:192 +0x8f
go.vocdoni.io/dvote/statedb.(*treeUpdateView).DeepGet(0x3c94224?, {0xc015c6a330?, 0x0?, 0xab?}, {0xc00316c000?, 0xc016ed0a00?, 0xc0175f3d08?})
	go.vocdoni.io/dvote/statedb/treeupdate.go:378 +0x1d
go.vocdoni.io/dvote/vochain/state.(*State).SIKFromAddress(0x3631ac0?, {0x2e, 0x5b, 0x2, 0x23, 0x7f, 0x44, 0x89, 0xd5, 0x3a, ...})
	go.vocdoni.io/dvote/vochain/state/sik.go:46 +0x145
go.vocdoni.io/dvote/api.(*API).accountHandler(0xc00f7696c0, 0x25cd77b?, 0xc016bf0b60)
	go.vocdoni.io/dvote/api/accounts.go:150 +0x4b8
go.vocdoni.io/dvote/httprouter/apirest.(*API).RegisterMethod.func1({{0x35ed6e0, 0xc01644eb70}, {0xc14fa044d614e10a, 0x50020feb9464, 0x5fbd0a0}, {0xc00cffa390, 0x3, 0x3}, 0xc016bf0b60})
	go.vocdoni.io/dvote/httprouter/apirest/apirest.go:229 +0x6b
created by go.vocdoni.io/dvote/httprouter.(*HTTProuter).AddPublicHandler.(*HTTProuter).routerHandler.func1 in goroutine 125010181
	go.vocdoni.io/dvote/httprouter/httprouter.go:283 +0x3c5
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

Successfully merging a pull request may close this issue.

2 participants