Skip to content

Commit

Permalink
Bug Fix:
Browse files Browse the repository at this point in the history
Copy over vs.value into item.vptr, otherwise, when item gets reused it
ends up overwriting a value pointer and cause panics. This is the bug
which ventured into v1.0.6 of Dgraph, and caused hard to locate panics.
  • Loading branch information
manishrjain committed Jul 11, 2018
1 parent a6f0866 commit a7cf7d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func replayFunction(out *DB) func(Entry, valuePointer) error {
first := true
return func(e Entry, vp valuePointer) error { // Function for replaying.
if first {
out.elog.Printf("First key=%s\n", e.Key)
out.elog.Printf("First key=%q\n", e.Key)
}
first = false

Expand Down
8 changes: 6 additions & 2 deletions iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,13 @@ func (item *Item) yieldItemValue() ([]byte, func(), error) {
if vs.Version != item.Version() {
return nil, nil, nil
}
item.vptr = vs.Value
// Bug fix: Always copy the vs.Value into vptr here. Otherwise, when item is reused this
// slice gets overwritten.
item.vptr = y.SafeCopy(item.vptr, vs.Value)
item.meta &^= bitValuePointer // Clear the value pointer bit.
item.meta |= vs.Meta // This meta would only be about value pointer.
if vs.Meta&bitValuePointer > 0 {
item.meta |= bitValuePointer // This meta would only be about value pointer.
}
}
}

Expand Down

0 comments on commit a7cf7d9

Please sign in to comment.