Skip to content

Commit

Permalink
Fix nil pointer access in Session.Check()
Browse files Browse the repository at this point in the history
The Session.Check() function wants to construct a multierr object from
"e", not "err". Fixes crashes if Query() result set iterator closing
fails for some reason:

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

  goroutine 60 [running]:
  github.com/scylladb/gemini.(*Session).Check.func1(0xc00011c7e0, 0xc000333cb0, 0xc00011cea0)
  	/home/penberg/go/src/github.com/scylladb/gemini/session.go:79 +0xb2
  github.com/scylladb/gemini.(*Session).Check(0xc00018e500, 0x8c95a0, 0xc0001aee00, 0x839610, 0x6, 0xc00000efe0, 0x1, 0x1, 0xc000012b80, 0x3, ...)
  	/home/penberg/go/src/github.com/scylladb/gemini/session.go:87 +0xd48
  main.validationJob(0x8c95a0, 0xc0001aee00, 0xc000096cc0, 0x839610, 0x6, 0xc00000efe0, 0x1, 0x1, 0xc000012b80, 0x3, ...)
  	/home/penberg/go/src/github.com/scylladb/gemini/cmd/gemini/root.go:296 +0x182
  main.Job(0x8c95a0, 0xc0001aee00, 0xc0001b87a0, 0xc000096cc0, 0x839610, 0x6, 0xc00000efe0, 0x1, 0x1, 0xc000012b80, ...)
  	/home/penberg/go/src/github.com/scylladb/gemini/cmd/gemini/root.go:331 +0x407
  created by main.runJob
  	/home/penberg/go/src/github.com/scylladb/gemini/cmd/gemini/root.go:209 +0x1f9
  • Loading branch information
penberg committed May 20, 2019
1 parent 74944b6 commit 0c69950
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ func (s *Session) Check(table Table, query string, values ...interface{}) (err e
oracleIter := s.oracleSession.Query(query, values...).Iter()
defer func() {
if e := testIter.Close(); e != nil {
err = multierr.Append(err, errors.Errorf("test system failed: %s", err.Error()))
err = multierr.Append(err, errors.Errorf("test system failed: %s", e.Error()))
}
if e := oracleIter.Close(); e != nil {
err = multierr.Append(err, errors.Errorf("oracle failed: %s", err.Error()))
err = multierr.Append(err, errors.Errorf("oracle failed: %s", e.Error()))
}
}()

Expand Down

0 comments on commit 0c69950

Please sign in to comment.