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

Avoid SIGSEGV in tromp solver #556

Closed
wants to merge 2 commits into from

Conversation

jmjatlanta
Copy link

@jmjatlanta jmjatlanta commented Jul 18, 2022

Fixes #555

The tromp equihash solver can sometimes get in the state whereby the nsols counter is greater than MAXSOLS. An attempt is then made to read an element of the array beyond the array size (index out of bounds). This fix limits the reads to a maximum of MAXSOLS.

TODO:

  • Build a unit test that verifies the problem and the fix.

@jmjatlanta jmjatlanta marked this pull request as ready for review July 19, 2022 03:10
@dimxy
Copy link
Collaborator

dimxy commented Jul 22, 2022

looks good

break;
}
}
check_tromp_solution(eq, validBlock);
Copy link

Choose a reason for hiding this comment

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

May be here we need:

if (check_tromp_solution(eq, validBlock))
    break;

To preserve the original logic? If we find a POW solution, do not try other solutions.

Copy link
Collaborator

Choose a reason for hiding this comment

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

As I can tell, check_tromp_solution does not change the original logic:
the original logic breaks the loop if a solution is found
and check_tromp_solution in this case just returns also breaking solution searching.
It looks like the boolean return is needed for tests only

Copy link

@DeckerSU DeckerSU Aug 1, 2022

Choose a reason for hiding this comment

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

Yes, seems you are right, sorry. The logic is fine.

p.s. It was "small display issue" (I mixed up the scopes somehow and what it breaks).

@ca333 ca333 requested review from DeckerSU, ca333 and Alrighttt August 4, 2022 09:15
DeckerSU added a commit to DeckerSU/KomodoOcean that referenced this pull request Aug 16, 2022
@DeckerSU
Copy link

LGTM.

nuttycom pushed a commit to zcash/zcash that referenced this pull request Aug 23, 2022
@tonymorony
Copy link

these changes implemented in combined PR: #559

@tonymorony tonymorony closed this Sep 5, 2022
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

Successfully merging this pull request may close these issues.

6 participants