From 51ed39c0933d0d2fffbc5d093d45872a84d960eb Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 7 Sep 2021 16:15:11 +0200 Subject: [PATCH] core: make txPricedList.stales the first field for 64bit alignment (#23542) This fixes crashes on 32bit builds. --- core/tx_list.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/tx_list.go b/core/tx_list.go index 1d5c336a1..ea96f3ebb 100644 --- a/core/tx_list.go +++ b/core/tx_list.go @@ -480,9 +480,14 @@ func (h *priceHeap) Pop() interface{} { // better candidates for inclusion while in other cases (at the top of the baseFee peak) // the floating heap is better. When baseFee is decreasing they behave similarly. type txPricedList struct { + // Number of stale price points to (re-heap trigger). + // This field is accessed atomically, and must be the first field + // to ensure it has correct alignment for atomic.AddInt64. + // See https://golang.org/pkg/sync/atomic/#pkg-note-BUG. + stales int64 + all *txLookup // Pointer to the map of all transactions urgent, floating priceHeap // Heaps of prices of all the stored **remote** transactions - stales int64 // Number of stale price points to (re-heap trigger) reheapMu sync.Mutex // Mutex asserts that only one routine is reheaping the list }