Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/msprime.c
Original file line number Diff line number Diff line change
Expand Up @@ -7690,7 +7690,7 @@ msp_smc_k_common_ancestor_event(

/* find second hull */
search = &x_hull->left_avl_node;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know quite what's going on, but I'd want to check that we're not getting search == NULL here and remaining_mass == 0 before the loop even starts. LMK if you'd like me to get my head around all this enough to double-check the correctness.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the problematic example I posted, I think that’s not the case.

Before entering the loop, search is not null and remaining_mass is exactly 1.0 (up to floating-point error, I guess).

At the end of the first iteration, remaining_mass is decreased by one (which makes remaining_mass==0) but search is still not null. That's the hull we chose when doing >0 instead of >=0.

The assertion error is triggered in the 3070th iteration when the loop finishes traversing the linked list and finds the NULL.

for (search = search->prev; remaining_mass >= 0; search = search->prev) {
for (search = search->prev; remaining_mass > 0; search = search->prev) {
tsk_bug_assert(search != NULL);
y_hull = (hull_t *) search->item;
if (y_hull->left == x_hull->left || y_hull->right > x_hull->left) {
Expand Down
Loading