{
 "number": 36556,
 "repo": "bitcoin/bitcoin",
 "url": "https://github.com/bitcoin/bitcoin/pull/36556",
 "title": "depends: fix non-atomic reads in capnp debug assertions",
 "author": "xyzconstant",
 "author_association": "CONTRIBUTOR",
 "created_at": "2026-10-17T00:22:30Z",
 "updated_at": "2026-10-21T16:50:10Z",
 "description_hash": "52cc84382924d143",
 "age_days": 16,
 "draft": false,
 "labels": [
  "Build system"
 ],
 "milestone": null,
 "base": "master",
 "head_sha": "6e8e85ddcf2eb4a062fab3cd2b9c046edfbf72ec",
 "head_ref": "depends-capnp-kj-atomic-reads",
 "head_repo": "xyzconstant/bitcoin",
 "head_history": [],
 "additions": 174,
 "deletions": 1,
 "changed_files": 3,
 "commit_count": 1,
 "size_bucket": "M",
 "mergeable_state": "clean",
 "bot": {
  "drahtbot": {
   "present": true,
   "reviews": {
    "ack": [
     {
      "login": "Sjors",
      "url": "https://github.com/bitcoin/bitcoin/pull/36556#issuecomment-6311264354"
     }
    ]
   },
   "conflicts": []
  }
 },
 "acks_parsed": {
  "Sjors": {
   "kind": "ack",
   "hash": "6e8e85ddcf2eb4a062fab3cd2b9c046edfbf72ec",
   "t": "2026-10-21T08:11:16Z",
   "stale": false
  }
 },
 "acks_tally": {
  "ack": 1,
  "stale_ack": 0,
  "concept_ack": 0,
  "approach_ack": 0,
  "nack": 0,
  "concept_nack": 0,
  "approach_nack": 0
 },
 "reviews": {
  "approved": 0,
  "changes_requested": 0,
  "distinct_reviewers": [
   "Sjors",
   "fanquake"
  ]
 },
 "signals": {
  "needs_rebase": false,
  "ci_failed": false,
  "mergeable_state": "clean",
  "last_author_activity": "2026-10-21T16:50:10Z",
  "last_reviewer_activity": "2026-10-21T08:11:16Z",
  "last_reviewer": "Sjors",
  "author_silent_days": 11,
  "waiting_on_author_days": 0,
  "days_since_update": 11
 },
 "refs": {
  "mentioned": [],
  "depends_on": [],
  "fixes": [],
  "linked_issues": [],
  "references": [],
  "conflicts": []
 },
 "stack": {
  "shares_commits_with": [],
  "based_on": [],
  "base_for": []
 },
 "review_paths": [],
 "body": "KJ's debug assertions read the mutex futex word and `AtomicRefcounted` refcounts non-atomically. The TSan job builds capnp without optimization, which automatically enables these assertions, and TSan reports these reads as data races the moment KJ objects start communicating across threads.\n\nlibmultiprocess enables cross-thread communication for the first time in bitcoin-core/libmultiprocess#376, which replaces the pipe used in `EventLoop::sync()` with `kj::Executor::executeSync()`. This is what triggered the [failure](https://github.com/bitcoin-core/libmultiprocess/actions/runs/38094008438/job/114336046070?pr=376).\n\nPatches are the upstream commits capnproto/capnproto@b91a6ba7c7 and capnproto/capnproto@cc13c8c45f, which are backports of the v2 fixes in capnproto/capnproto#2781 and capnproto/capnproto#2843 (backport PR: capnproto/capnproto#2855).",
 "commits": [
  {
   "sha": "6e8e85ddcf2eb4a062fab3cd2b9c046edfbf72ec",
   "date": "2026-10-17T00:17:07Z",
   "message": "depends: fix non-atomic reads in capnp debug assertions\n\nKJ's debug assertions read the mutex futex word and `AtomicRefcounted`\nrefcounts non-atomically. The TSan job builds capnp without optimization,\nwhich automatically enables these assertions, and TSan reports these reads\nas data races the moment KJ objects start communicating across threads.\n\nlibmultiprocess enables cross-thread communication for the first time\nin https://github.com/bitcoin-core/libmultiprocess/pull/376, which replaces\nthe pipe used in `EventLoop::sync()` with `kj::Executor::executeSync()`.\n\nPatches are the upstream commits\nhttps://github.com/capnproto/capnproto/commit/b91a6ba7c7 and\nhttps://github.com/capnproto/capnproto/commit/cc13c8c45f, which are backports\nof the v2 fixes in capnproto/capnproto#2781 and capnproto/capnproto#2843\n(https://github.com/capnproto/capnproto/pull/2855)."
  }
 ],
 "timeline": [
  {
   "t": "2026-10-19T07:41:27Z",
   "kind": "comment",
   "who": "fanquake",
   "assoc": "MEMBER",
   "text": "cc @Sjors @ryanofsky",
   "id": "c:6262222850",
   "url": "https://github.com/bitcoin/bitcoin/pull/36556#issuecomment-6262222850",
   "hash": "9053fe703ea46525",
   "edited": null
  },
  {
   "t": "2026-10-21T08:11:16Z",
   "kind": "comment",
   "who": "Sjors",
   "assoc": "MEMBER",
   "text": "ACK 6e8e85ddcf2eb4a062fab3cd2b9c046edfbf72ec\n\nI verified that the patches match upstream, and that TSan needs both (if we continue with https://github.com/bitcoin-core/libmultiprocess/pull/376).\n\nIf we want capnp's tests to pass under TSan, we'd have to backport several other changes. But given that we set `BUILD_TESTING=OFF`, I guess it's unnecessary to backport things just to make tests pass? (I did manage locally)",
   "id": "c:6311264354",
   "url": "https://github.com/bitcoin/bitcoin/pull/36556#issuecomment-6311264354",
   "hash": "b898dfffdc3d32aa",
   "edited": null
  },
  {
   "t": "2026-10-21T16:50:10Z",
   "kind": "comment",
   "who": "xyzconstant",
   "assoc": "CONTRIBUTOR",
   "text": "Thanks @Sjors! I'm not sure which exact tests would fail and need backports, but I'd lean toward keeping `BUILD_TESTING=OFF` as you said, so we don't unnecessarily backport things just to make them work.",
   "id": "c:6321506048",
   "url": "https://github.com/bitcoin/bitcoin/pull/36556#issuecomment-6321506048",
   "hash": "7f6219ef87236dd7",
   "edited": null
  }
 ],
 "labels_log": [
  {
   "t": "2026-10-17T00:22:34Z",
   "action": "labeled",
   "label": "Build system",
   "who": "DrahtBot"
  }
 ],
 "state_log": [],
 "text_chars": 2426,
 "text_tokens_estimate": 606,
 "changed_paths": [
  "depends/packages/capnp.mk",
  "depends/patches/capnp/kj_atomicaddref_atomic_read.patch",
  "depends/patches/capnp/kj_mutex_atomic_futex_reads.patch"
 ],
 "files": [
  {
   "path": "depends/packages/capnp.mk",
   "add": 5,
   "del": 1
  },
  {
   "path": "depends/patches/capnp/kj_atomicaddref_atomic_read.patch",
   "add": 104,
   "del": 0
  },
  {
   "path": "depends/patches/capnp/kj_mutex_atomic_futex_reads.patch",
   "add": 65,
   "del": 0
  }
 ],
 "test_lines": 0,
 "git": {
  "head": "6e8e85ddcf2eb4a062fab3cd2b9c046edfbf72ec",
  "head_matches_backup": true,
  "base": "924f4c4ac78b0cd3b917c694f42c0651a6f3003a",
  "patch_id": "0cb6d896836fe837",
  "commits": [
   {
    "sha": "6e8e85ddcf",
    "subject": "depends: fix non-atomic reads in capnp debug assertions",
    "files": 3,
    "add": 174,
    "del": 1
   }
  ],
  "patch_truncated": false
 },
 "patch_id": "0cb6d896836fe837",
 "input_hash": "f2e6026f51751a8d",
 "extracted_at": "2026-11-02T01:09:49+00:00"
}