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

Bug: Race-like situation leads to nil-pointer panic in replace cursor #1850

Closed
etiennedi opened this issue Mar 10, 2022 · 1 comment · Fixed by #1859
Closed

Bug: Race-like situation leads to nil-pointer panic in replace cursor #1850

etiennedi opened this issue Mar 10, 2022 · 1 comment · Fixed by #1859
Assignees

Comments

@etiennedi
Copy link
Member

Discovered during the investigation of #1849:

In the following place the Lock is obtained to late. A compaction can (and as our stress tests show will) happen between creating the slice and filling it. Thus we leave empty slots which will lead to a nil-pointer panic down the line

func (s *SegmentGroup) newCursors() ([]innerCursorReplace, func()) {
  out := make([]innerCursorReplace, len(s.segments))
  s.maintenanceLock.RLock()

  for i, segment := range s.segments {
    out[i] = segment.newCursor()
  }

  return out, s.maintenanceLock.RUnlock
}

Notes

  • Check if the same issue also occurs for the other two cursor types (map/set) and fix if required.
  • Validate either through direct test or through external stress-test
@etiennedi etiennedi self-assigned this Mar 10, 2022
@etiennedi
Copy link
Member Author

Update: Nothing to do for the other two types (map/set), there the lock is in the right place.

etiennedi added a commit that referenced this issue Mar 10, 2022
There was a small data race where a compaction could have already
occurred/finished between creating the array and initializing it, thus
leaving empty slots.

There is no test yet, as this will be tested through the stress-test
pipelines together with a potential fix for #1849
etiennedi added a commit that referenced this issue Mar 14, 2022
…0-replace-segfault

gh-1850 fix nil-pointer in segment cursor
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.

1 participant