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

Buffer overflow in cpu/rw.cpp #45

Closed
darabos opened this issue Jan 14, 2020 · 1 comment
Closed

Buffer overflow in cpu/rw.cpp #45

darabos opened this issue Jan 14, 2020 · 1 comment

Comments

@darabos
Copy link

darabos commented Jan 14, 2020

      cur = col_d[cum_deg_d[cur] +
                  int64_t(rand_d[n * walk_length + (l - 1)] * deg_d[cur])];

If deg_d[cur] is 0, this will give the wrong result. (It will follow an edge that belongs to another node.) If additionally this is the last vertex, it will overflow col_d. If walk_length is 1, it will just give you walks with very high vertex IDs. With longer walks it will segfault.

>>> torch_cluster.rw_cpu.rw(torch.tensor([0, 0, 2, 1]), torch.tensor([1, 2, 3, 3]), torch.tensor([0, 1, 2, 3]), 1, 1, 1, 4) 
tensor([[              0,               1],
        [              1,               3],
        [              2,               3],
        [              3, 140686418058400]])

The CUDA implementation is different, but I think it also generates incorrect walks:

      out[l * numel + n] = col[row[cur] + int64_t(rand[i] * deg[cur])];

How is the algorithm supposed to handle nodes with no outgoing edges? Producing shorter walks when we hit such a node is probably out of the question. Maybe we could just keep repeating the same node then? That would be easy to implement at least.

@rusty1s
Copy link
Owner

rusty1s commented Sep 16, 2021

Sorry for missing this issue. This was resolved long time ago :)

@rusty1s rusty1s closed this as completed Sep 16, 2021
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

2 participants