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

Fix external/picosat undefined behaviour. #2375

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kevemueller
Copy link

Suggested fix was reported to Prof. Biere by email.

@arrowd
Copy link
Contributor

arrowd commented Dec 2, 2024

I remember stumbling upon this when playing with UBSan, but I didn't get to fix it properly.
Thanks for that!

@kevemueller
Copy link
Author

Hi Gleb,

please have a close look as well as I miss the depth of PicoSAT knowledge that you have. I interpreted this as a simple start/end pointer comparison with the edge case of both not initialized (i.e. NULL).

Cheers,
K

@arrowd
Copy link
Contributor

arrowd commented Dec 2, 2024

IIRC, the UB was coming from doing a pointer arithmetic on a possible NULL pointer. So I'd rephrase the fix as

if (ps->thead != NULL && ps->trail != NULL)
  return  ps->thead == ps->trail + ps->max_var;
else
  return 0;

@kevemueller
Copy link
Author

kevemueller commented Dec 2, 2024 via email

@arrowd
Copy link
Contributor

arrowd commented Dec 2, 2024

Right, but then just if (ps->trail != NULL) should suffice?

Slightly simplified after discussion with @arrowd.
@kevemueller
Copy link
Author

Correct! I have simplified the clause.
Thx!

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.

2 participants