Zero the PetscBool output refs - #269
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PetscBooloutputs were passed as an uninitialisedRef{PetscBool}(). On 3.25 the library writes only the low byte of that 4-byte slot, so a false result reads as true whenever the top three bytes aren't zero, sinceBoolis true if any bit is set. Zeroing the slot is correct for both releases on little-endian: 3.22 writes four bytes, 3.25 writes one.Declaring the type as 8 bits instead would break 3.22, and 0.4.x binds both, so the slot rather than the declaration is what has to change.
446 refs across 43 files, plus the one emission site in
wrapping/generatejuliabindings.jlso regeneration keeps it.src/startup.jlisn't included (src/PETSc.jl:66), but I fixed the ref there too rather than leave a copy of the bug behind.Tests pass on 3.22.2 with Julia 1.10 and on 3.25.4 with Julia 1.12.
No regression test: a freshly allocated ref is always zero in practice, which is why this is latent undefined behaviour rather than a reproducible wrong answer.
Fixes #268