Skip to content

fix: indices stack overflow#3

Open
saul-jb wants to merge 1 commit intofission-codes:masterfrom
saul-jb:fix/indices-stack-overflow
Open

fix: indices stack overflow#3
saul-jb wants to merge 1 commit intofission-codes:masterfrom
saul-jb:fix/indices-stack-overflow

Conversation

@saul-jb
Copy link
Copy Markdown

@saul-jb saul-jb commented Feb 12, 2024

The bloom filter's getDistinctIndexes with some inputs can cause a stack overflow.

The code reproduces this error:

import { BloomFilter } from 'fission-bloom-filters'

const f = new BloomFilter(5, 4)

f.seed = 2000679582

const raw = new Uint8Array([0x01, 0x71, 0x12, 0x20, 0x9c, 0x4e, 0x9b, 0x9f, 0x68, 0x6b, 0xeb, 0xd1, 0xf2, 0x2b, 0x65, 0x1f, 0x0a, 0x72, 0xf8, 0xb3, 0x14, 0xb7, 0xd1, 0x13, 0xb0, 0x58, 0xa6, 0x72, 0xf2, 0x09, 0x42, 0xe0, 0x04, 0x19, 0xcb, 0x80])
const item = raw.buffer.slice(raw.byteOffset, raw.byteLength + raw.byteOffset)

f.add(item)

This PR updates the method to match the upstream implementation.

This PR seems to break a couple of the Invertible Bloom Lookup Tables test cases (collisions?):

  58 passing
  2 failing

  1) Invertible Bloom Lookup Tables
       Set differences of [10 to 100] with 1000 keys, 3 hash functions, [alpha = 1.5, d = 100]=150 cells
         should decodes correctly element for a set difference of 100:

      AssertionError: expected false to equal true
      + expected - actual

      -false
      +true
      
      at commonTest (test/iblt-test.js:220:26)
      at Context.<anonymous> (test/iblt-test.js:180:9)
      at process.processImmediate (node:internal/timers:476:21)

  2) Invertible Bloom Lookup Tables
       [Performance] Set differences of [10 to 100] with 1000 keys, 3 hash functions, [alpha = 1.5, d = 100]=150 cells
         should decodes correctly element for a set difference of 100:

      AssertionError: expected false to equal true
      + expected - actual

      -false
      +true
      
      at commonTest (test/iblt-test.js:220:26)
      at Context.<anonymous> (test/iblt-test.js:187:9)
      at process.processImmediate (node:internal/timers:476:21)

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 this pull request may close these issues.

1 participant