You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Baxos encoding crashes when using PRNG input in parallel threads. #5
Hello, I want to encode an OKVS object with baxos.solve. In addition, I want to input a PRNG for randomizing all 0 positions in the OKVS objects and make the encoding phase parallel. However, a segmentation fault always occurs when running the statement like baxos.solve<block>(in, values, okvs, &prng, kThrdNum);
Here is my code, which may reproduce the above error.
We hit the same crash and tracked it down; details below in case they help.
Disclosure: this was found by Claude (Anthropic's AI model) during an audit of code that uses volePSI, and Claude
drafted this comment. Every number comes from a run that was actually made.
Cause. In Baxos::implParSolve (volePSI/PaxosImpl.h) every worker thread passes the same PRNG* to paxos.encode(values, output, h, prng). PRNG is not thread-safe: two threads advancing its buffer position at
once can push it past the end of the buffer, after which PRNG::implGet copies out of bounds (the segfault in this
issue). RsOpprfSender::send passes a PRNG too, so the OPPRF and circuit-PSI senders hit this with more than one
thread.
Still present on current main (f46d8bb, pinned dependencies, Release, x86-64, GCC 14.2): upstream's own frontend -perf -cpsi -nn 22 segfaults 3 of 3 runs at 8 threads and 5 of 5 at 4 threads. A direct Baxos::solve<block>(..., &prng, nt) with the OPPRF parameters crashes in 26 to 50 of 50 runs at 8 threads for
n = 2^16 to 2^20 (and already 24 of 50 at 2 threads for n = 2^18).
Fix. Seed one PRNG per worker from the caller's before the threads start (11 lines). With it: 0 crashes in all of
the above, no decode mismatches, and frontend -u passes (56 tests). One side effect: for a given seed the solved
table changes, which no test depends on.
--- a/volePSI/PaxosImpl.h+++ b/volePSI/PaxosImpl.h@@ -2783,8 +2783,18 @@
std::promise<void> hashingDoneProm;
auto hashingDoneFu = hashingDoneProm.get_future().share();
+ // PRNG is not thread-safe, so give each worker its own, seeded from the caller's.+ std::vector<PRNG> thrdPrngs;+ if (prng)+ {+ thrdPrngs.reserve(numThreads);+ for (u64 t = 0; t < numThreads; ++t)+ thrdPrngs.emplace_back(prng->get<block>());+ }+
auto processBins = [&](u64 thrdIdx, bool& countedDone)
{
+ PRNG* thrdPrng = prng ? &thrdPrngs[thrdIdx] : nullptr;
auto begin = (inputs_.size() * thrdIdx) / numThreads;
auto end = (inputs_.size() * (thrdIdx + 1)) / numThreads;
auto inputs = inputs_.subspan(begin, end - begin);
@@ -2986,7 +2996,7 @@
}
paxos.setInput(rows, hashes, cols, colBacking, colWeights);
- paxos.encode(values, output, h, prng);+ paxos.encode(values, output, h, thrdPrng);
}
};
Happy to open a pull request with this and a multi-threaded Baxos::solve test with a PRNG.
Fixed in #18: parallel Baxos now uses an independent PRNG per worker. On current main, 50 eight-thread randomized solve/decode runs at 2^20 items and 100 at 2^18 completed without a crash or mismatch.
Activity
verdelyi commentedon Nov 16, 2026
We hit the same crash and tracked it down; details below in case they help.
Disclosure: this was found by Claude (Anthropic's AI model) during an audit of code that uses volePSI, and Claude
drafted this comment. Every number comes from a run that was actually made.
Cause. In
Baxos::implParSolve(volePSI/PaxosImpl.h) every worker thread passes the samePRNG*topaxos.encode(values, output, h, prng).PRNGis not thread-safe: two threads advancing its buffer position atonce can push it past the end of the buffer, after which
PRNG::implGetcopies out of bounds (the segfault in thisissue).
RsOpprfSender::sendpasses a PRNG too, so the OPPRF and circuit-PSI senders hit this with more than onethread.
Still present on current main (
f46d8bb, pinned dependencies, Release, x86-64, GCC 14.2): upstream's ownfrontend -perf -cpsi -nn 22segfaults 3 of 3 runs at 8 threads and 5 of 5 at 4 threads. A directBaxos::solve<block>(..., &prng, nt)with the OPPRF parameters crashes in 26 to 50 of 50 runs at 8 threads forn = 2^16 to 2^20 (and already 24 of 50 at 2 threads for n = 2^18).
Fix. Seed one PRNG per worker from the caller's before the threads start (11 lines). With it: 0 crashes in all of
the above, no decode mismatches, and
frontend -upasses (56 tests). One side effect: for a given seed the solvedtable changes, which no test depends on.
Happy to open a pull request with this and a multi-threaded
Baxos::solvetest with a PRNG.ladnir commentedon Nov 16, 2026
yeah, working on a fix and a larger update. getting faster and hardening the implementation/cryptography
ladnir commentedon Nov 18, 2026
Fixed in #18: parallel Baxos now uses an independent PRNG per worker. On current main, 50 eight-thread randomized solve/decode runs at 2^20 items and 100 at 2^18 completed without a crash or mismatch.