Skip to content

Segfault if gallopingSearchLeftPBounds is used with too large u #33

Description

@nh2

This illegal use of gallopingSearchLeftPBounds segfaults in ghci 8.6.5:

import           Data.Vector.Algorithms.Search (binarySearchP, gallopingSearchLeftPBounds, binarySearch)
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector as V

v <- V.thaw $ V.fromList [1,2,3]

gallopingSearchLeftPBounds (2 <) v 0 10

Note I give u = 10 when the maximum allowed values is 3 for the vector [1,2,3].

So it's expected that it fails.

However, a segfault is not expected, because I compile with default flags boundschecks = Enabled, and I the function doesn't have unsafe in the name or the docs, so I would expect a bounds check to happen.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions