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

Segmentation fault after insertions/lookups/deletions #1

Closed
shachaf opened this issue Jun 23, 2020 · 0 comments
Closed

Segmentation fault after insertions/lookups/deletions #1

shachaf opened this issue Jun 23, 2020 · 0 comments
Assignees

Comments

@shachaf
Copy link

shachaf commented Jun 23, 2020

I was testing this library and I ran into a segmentation fault. Here's a program that reproduces it:

$ cat alex-test.cc
#include <stdio.h>

#include "ALEX/src/core/alex_map.h"

int main(int argc, char **argv) {
  alex::AlexMap<uint64_t, uint64_t> map;

  FILE *f = fopen("alex-test-input.txt", "r");
  while (1) {
    char buf[100];
    char *line = fgets(buf, sizeof buf, f);
    if (!line) break;

    uint64_t key;
    if (line[0] == 'a') {
      sscanf(line, "a %lu", &key);
      printf("assign %lu\n", key);
      map[key] = 0;
    } else if (line[0] == 'd') {
      sscanf(line, "d %lu", &key);
      auto it = map.find(key);
      if (!it.is_end()) {
        printf("delete %lu\n", key);
        map.erase(it);
      } else {
        printf("!found %lu\n", key);
      }
    }
  }

  return 0;
}
$ clang++ -g alex-test.cc -o build/alex-test -march=haswell && ./build/alex-test > /dev/null
Segmentation fault

Here's a stack trace:

#0  0x000000000040a456 in alex::Alex<unsigned long, unsigned long, alex::AlexCompare, std::allocator<std::pair<unsigned long, unsigned long> >, false>::expand_root (
    this=0x7fffffffdb10, expand_left=true) at ./ALEX/src/core/alex.h:1454
#1  0x00000000004081f8 in alex::Alex<unsigned long, unsigned long, alex::AlexCompare, std::allocator<std::pair<unsigned long, unsigned long> >, false>::insert (this=0x7fffffffdb10,
    key=@0x7fffffffda80: 9178834004329713693, payload=@0x7fffffffd9d8: 0)
    at ./ALEX/src/core/alex.h:1117
#2  0x000000000040327d in alex::AlexMap<unsigned long, unsigned long, alex::AlexCompare, std::allocator<std::pair<unsigned long, unsigned long> > >::operator[] (
    this=0x7fffffffdb10, key=@0x7fffffffda80: 9178834004329713693)
    at ./ALEX/src/core/alex_map.h:128
#3  0x0000000000401640 in main (argc=1, argv=0x7fffffffdce8) at alex-test.cc:18

Here's the test input: https://slbkbs.org/tmp/alex-test-input.txt

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

No branches or pull requests

3 participants