Skip to content

cnf: keep Cnf_CutDeriveTruth's truth tables per call - #14

Merged
aytey merged 1 commit into
pin-two-commitsfrom
cnffast-reentrant-scratch
Sep 25, 2026
Merged

aytey merged 1 commit into
pin-two-commitsfrom
cnffast-reentrant-scratch

Conversation

@aytey

@aytey aytey commented Sep 24, 2026

Copy link
Copy Markdown
Member

Cnf_CutDeriveTruth() evaluated a cut's truth table into a static `word S[256]`, so two managers deriving CNF on separate threads wrote the same array. STP documents that independent managers may be used on separate threads; ThreadSanitizer reports this as the only race in ABC when independent STP instances bit-blast concurrently, and it surfaces as a rare crash (about one in a thousand runs of STP's concurrent-managers test).

The array becomes local to the call. It is filled before it is read on every call, so nothing that a static would have preserved carries over. Truth6 and C stay static: they are constant tables that are only read.

This is based on b6e26a0, the commit STP pins today, so STP can move its pin to this change alone. With it merged, STP drops the fetch-time patch it currently carries for the same line.

Cnf_CutDeriveTruth() evaluated a cut's truth table into a static
word S[256]. Two managers deriving CNF on separate threads therefore
wrote the same array, and a cut's table could be overwritten by another
thread's between the write and the read. ThreadSanitizer reports the
race when independent STP instances bit-blast concurrently, and it
surfaces as a rare crash in the caller.

Make the array local to the call. It is 2 KiB of stack, filled before
it is read on every call, so nothing carries over from one call to the
next that a static would have preserved. Truth6 and C stay static:
they are constant tables that are only read.

Assisted-by: Claude, via Claude Code
@aytey
aytey merged commit b1e6f8f into pin-two-commits Sep 25, 2026
16 of 18 checks passed
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.

1 participant