axiak / pybloomfiltermmap

Fast Python Bloom Filter using Mmap
http://axiak.github.com/pybloomfiltermmap/
MIT License
741 stars 137 forks source link

Segmentation faults with in-memory BloomFilter #44

Closed dbishop closed 10 years ago

dbishop commented 10 years ago

If you create an in-memory BloomFilter (i.e. no filename argument passed to BloomFilter.__init__) some actions can segfault.

Given, bloom_filter = BloomFilter(1000, 0.01), the following actions segfault:

The root cause is that attempting to access self._bf.array.filename actually triggers the segfault.

There's no reasonable value for bloom_filter.name on an in-memory BloomFilter if that attribute is always supposed to be an actual file on disk. But raising something like NotImplementedError would be preferable to a segfault.

For copy() and to_base64(), they could both get their job done if they accessed the raw data through mmap instead of having to go through a file on disk. But that's a pretty good-sized code change, so raising NotImplementedError there would be fine. If you want those functions, back your filter with a file.