-
Notifications
You must be signed in to change notification settings - Fork 13
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 when using filtration vertex_degree #16
Comments
Hi Julián, Could you quickly share the exact commit+the operating system you are running the code on? I could not reproduce the problem on my machine (latest master commit, MacOS). Does it consistently segfault? daniel ~/programming/flagser master [?? 3]
$ ./flagser --out ./test/tmp_d5_vertex_degree --out-format barcode --filtration vertex_degree --undirected --max-dim 1 ./test/d5.flag
The dimensions of the mod-2 homology of the full complex are:
dim H_0 = 1
dim H_1 = 0
daniel ~/programming/flagser master [?? 4]
$ Best, |
Hi Daniel, Thank you for the feedback. I work on Ubuntu 18.04, my compiler is GCC version 7.5.0. Best, |
I profiled the error, it's raised in The segfaults raises because I tried to change the rule from Do you have an idea how to fix this ? A supposition on why this does work on your machine, is because the memory is maybe initialized to 0, then if it reads out of bouds, it's only reading 0. This is only a supposition. Best, |
Well I tested changing as follow in from: boundary_filtration[i] = current_filtration[bdry.vertex(i)]; To: auto tmp = bdry.vertex(i);
boundary_filtration[i] = current_filtration[tmp > size ? 0 : tmp]; No segfaults is raised and the barcodes are good. BTW, I let the condition original It's a hacky way of achieving something that seems to work, but I would like to have your feedback. Best, PS: Sorry for the spam ... |
Just checked, for me bdry.vertex(i) never gives high values, when I print all those values my output is:
Are you sure that the input file is not modified? Can you print those numbers? If anything, then the problem should lie there, I think. Checked it on MacOS and CentOS. Thanks for checking! |
Hi, Really interesting the issue I'm encountering. Now that I updated to latest commit, sometimes it work and sometimes it generated the segfault. I slightly modified the printing, because when streams are done in parallel, the output can be quite noisy. When it works, I encounter this output for 2omputing the filtration of all edges
0
1
3
0
4
0
2
0
3
0
4
0
4
3
0
4
0
0
0
The dimensions of the mod-2 homology of the full complex are:
dim H_0 = 1
dim H_1 = 0 It's different from yours, because this method is run in parallel, now that I'm thinking about it, maybe I'm encountering a race condition, but strange why only with filtration equals When it fails, I've usually something that shows this: 1omputing the filtration of all edges
0
2
0
3
0
4
0
2
0
3
0
4
0
4
32687
32687 vs 5
[2] 24325 segmentation fault (core dumped) ./flagser --out ./test/tmp_d5_vertex_degree --out-format barcode --filtration BTW, I'm running my tests with the following command: |
And about the input data, I printed it when it fails and when it success, both the same:
I'll try to explore the possibility of a race condition. |
I think I found out the issue, the backtrace (not the complete, just important points) is as follow: 0. boundary_filtration[i] = current_filtration[bdry.vertex(i)]; // i == 1
1. f(prefix, prefix_size); // prefix_size == 2
2. complex.for_each_cell(compute_filtration, 1); The segfault arise because 1 // return vertices[1];
2 // return vertices[2]; Which is correct in the sense of the current implementation: for (int i = 0; i < size; i++) {
// Creates object of type directed_flag_complex_boundary_cell_t with bdry.i == i
auto bdry = cell.boundary(i);
if (!cell_hash.size()) {
std::cerr << (std::to_string(bdry.vertex(i)) + " vs " + std::to_string(current_filtration.size()) + "\n");
if (bdry.vertex(i) >= current_filtration.size()) {
std::cerr << bdry.vertex(i) << " vs " << current_filtration.size() << std::endl;
}
boundary_filtration[i] = current_filtration[bdry.vertex(i)];
} else {
...
}
} // When i == 0 in the previous for loop we obtain this bdry.vertex(0)
return vertices[0 + (0 < 0 ? 0 : 1)]; // vertices[0 + 1]
// When i == 1 in the previous for loop we obtain this bdry.vertex(1)
return vertices[1 + (1 < 1 ? 0 : 1)]; // vertices[1 + 1] But the problem is that From the previous line, A easy hack would be to change Hopefully all this debug of the code helps you, Julián |
Hi, Thanks for digging this deep! Indeed there is a problem here, to lookup the filtration values of the vertices of an edge we looked at the i-th vertex of the i-th face, i.e. the 0th vertex of the 0th face and the 1st vertex of the first face. That second one is obviously non-existent since a face of an edge only has a single vertex. Switching to reading the 0th vertex of the i-th face fixes that problem. Please test out the code in #19 , I will merge as soon as you confirm. Thanks! Best, |
Hi, Niceuu ! Have a nice week-end and take care, |
Happy to hear that. Thanks a lot for all the debugging, made it super easy to fix it. Have a great weekend, and stay healthy! Cheers, |
Hi,
Currently working on the library, I just stumbled on a segmentation fault.
To reproduce the segmentation fault do as follow:
I would expect it does not SIGSEGV.
I'm currently busy with other tasks, but if I have some time, I'll try to explore the issue.
Let met know if this is expected behaviour, even if I would expect more an exception to be raised.
Take care and have a nice day,
Julián
The text was updated successfully, but these errors were encountered: