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

Vector subscript out of range #1

Open
Vancasola opened this issue Nov 21, 2018 · 0 comments
Open

Vector subscript out of range #1

Vancasola opened this issue Nov 21, 2018 · 0 comments

Comments

@Vancasola
Copy link

Hello, when I try to update the sketch, the program suddenly stop, and show:Vector Subscript out of range.

First, I run it on Ubuntu 16.04, but the program stoped and the terminal only to display:Floating point exception (core dumped). I have added c++11 optional.

For convenience, I run it on Visual Studio 2017, but it was stopped too. When the program is running, a windows show: Debug Assertion Failed : Vector subscript out of range.

error

And I find the array.find() of unordered_map leads to the failure. I find that the hash value may be negtive when the type of hash functions's returned value transform(from usigned int to long long), and the vector subscript may be out of range. So I limit the hash value to be positive, even decrease the hash value, but it dosen't work.

I test Object for equality and Object for hash, they seemly work well.

this is my code:
`int main(int argc, char** argv) {

LDSketch_t* lds = LDSketch_init(10000, 4, 1, 64, 1024*1024, 0);
dyn_tbl_key_t key;

memcpy(key.key, "abc", lds->lgn / 8);
dyn_tbl_t *test = (dyn_tbl_t*)safe_calloc(10000 * 4, sizeof(long long), std::string("tbl->tbl").c_str());

LDSketch_update(lds, key.key, (long long)5);//stop and out of range
printf("%ld", test->array.find(key));//stop and out of range
LDSketch_destroy(lds);
system("PAUSE");
return 0;

}`

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

1 participant