Skip to content

SIGFPE Error: packed_vector.hpp:996: void rebuild_rem(uint64_t j, uint8_t new_width_): Assert (size_ / int_per_word_ + (size_%int_per_word_!=0) <= words.size()) #29

@jikhashkya

Description

@jikhashkya

Hi there @nicolaprezza,

I ran into this bug which seems to be triggered when deleting the last element from packed_spsi. It seems the last element cannot be a non-zero element in this specific instance. If I set the last element to zero before removing it, it seems to work fine (see the comment out code below). A similar issue seems to have been closed before so I'm not sure if this is related to that.

The following code should replicate the bug:

#include <iostream>
#include <random>
#include "dynamic/dynamic.hpp"

using namespace std;
using namespace dyn;

int main() {

  packed_spsi my_spsis;
  std::random_device rd;
  std::mt19937 mt(rd());
  std::uniform_int_distribution<std::mt19937::result_type> dist6(0,100); 
  cout << "Inserting random values: \n";
  for (int i = 0; i < 2000; ++i) {
    auto rand_val = static_cast<unsigned int>(dist6(mt));
    cout << i << ". Inserting val " << rand_val << "\n";
    my_spsis.push_back(rand_val);
  }

  cout << "Deleting random values: \n";
  for (int i = 0; i < 2000; ++i) {
    cout << i << ". Deleting \n";
    assert(my_spsis.size() > 0);
    // Uncomment to avoid the bug
    // if (my_spsis.size() == 1){
    //  my_spsis.set(0, 0);
    // }
    my_spsis.remove(0);
  }
}

Hope this gets fixed soon. Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions