[PR #1355] [MERGED] Correct broken unaligned load/store in armv5 #15875

Closed
opened 2025-11-02 11:56:38 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/gitea/pull/1355
Author: @psolyca
Created: 3/21/2017
Status: Merged
Merged: 4/6/2017
Merged by: @lunny

Base: masterHead: master


📝 Commits (1)

  • 2f70a4d Correct broken unaligned load/store in armv5

📊 Changes

19 files changed (+320 additions, -74 deletions)

View changed files

📝 vendor/github.com/boltdb/bolt/README.md (+79 -12)
📝 vendor/github.com/boltdb/bolt/bolt_386.go (+3 -0)
📝 vendor/github.com/boltdb/bolt/bolt_amd64.go (+3 -0)
📝 vendor/github.com/boltdb/bolt/bolt_arm.go (+21 -0)
📝 vendor/github.com/boltdb/bolt/bolt_arm64.go (+3 -0)
📝 vendor/github.com/boltdb/bolt/bolt_mips64.go (+3 -0)
📝 vendor/github.com/boltdb/bolt/bolt_mips64le.go (+3 -0)
📝 vendor/github.com/boltdb/bolt/bolt_ppc64.go (+3 -0)
📝 vendor/github.com/boltdb/bolt/bolt_ppc64le.go (+3 -0)
📝 vendor/github.com/boltdb/bolt/bolt_s390x.go (+3 -0)
📝 vendor/github.com/boltdb/bolt/bolt_windows.go (+1 -1)
📝 vendor/github.com/boltdb/bolt/bucket.go (+32 -3)
📝 vendor/github.com/boltdb/bolt/db.go (+66 -20)
📝 vendor/github.com/boltdb/bolt/errors.go (+2 -1)
📝 vendor/github.com/boltdb/bolt/freelist.go (+29 -19)
📝 vendor/github.com/boltdb/bolt/node.go (+5 -0)
📝 vendor/github.com/boltdb/bolt/page.go (+31 -6)
📝 vendor/github.com/boltdb/bolt/tx.go (+21 -3)
📝 vendor/vendor.json (+9 -9)

📄 Description

This PR fixes issue #1354.

armv5 devices and older (i.e. <= arm9 generation) require addresses that are stored to and loaded from to to be 4-byte aligned.

If this is not the case the lower 2 bits of the address are cleared and the load is performed in an unexpected order, including up to 3 bytes of data located prior to the address.

Inlined buckets are stored after their key in a page and since there is no guarantee that the key will be of a length that is a multiple of 4, it is possible for unaligned load/stores to occur when they are cast back to bucket and page pointer types.

The fix adds a new field to track whether the current architecture exhibits this issue, sets it on module load for ARM architectures, and then on bucket open, if this field is set and the address is unaligned, a byte-by-byte copy of the inlined bucket is performed.

The fixe commes from 97aba5586d
and has already been applied in the upstream boltdb repository https://github.com/boltdb/bolt/pull/578

I already tested this fixe on my armv5 board with success.

Thanks


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-gitea/gitea/pull/1355 **Author:** [@psolyca](https://github.com/psolyca) **Created:** 3/21/2017 **Status:** ✅ Merged **Merged:** 4/6/2017 **Merged by:** [@lunny](https://github.com/lunny) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (1) - [`2f70a4d`](https://github.com/go-gitea/gitea/commit/2f70a4ddd445b499e22b44e89794f33b71fbd020) Correct broken unaligned load/store in armv5 ### 📊 Changes **19 files changed** (+320 additions, -74 deletions) <details> <summary>View changed files</summary> 📝 `vendor/github.com/boltdb/bolt/README.md` (+79 -12) 📝 `vendor/github.com/boltdb/bolt/bolt_386.go` (+3 -0) 📝 `vendor/github.com/boltdb/bolt/bolt_amd64.go` (+3 -0) 📝 `vendor/github.com/boltdb/bolt/bolt_arm.go` (+21 -0) 📝 `vendor/github.com/boltdb/bolt/bolt_arm64.go` (+3 -0) 📝 `vendor/github.com/boltdb/bolt/bolt_mips64.go` (+3 -0) 📝 `vendor/github.com/boltdb/bolt/bolt_mips64le.go` (+3 -0) 📝 `vendor/github.com/boltdb/bolt/bolt_ppc64.go` (+3 -0) 📝 `vendor/github.com/boltdb/bolt/bolt_ppc64le.go` (+3 -0) 📝 `vendor/github.com/boltdb/bolt/bolt_s390x.go` (+3 -0) 📝 `vendor/github.com/boltdb/bolt/bolt_windows.go` (+1 -1) 📝 `vendor/github.com/boltdb/bolt/bucket.go` (+32 -3) 📝 `vendor/github.com/boltdb/bolt/db.go` (+66 -20) 📝 `vendor/github.com/boltdb/bolt/errors.go` (+2 -1) 📝 `vendor/github.com/boltdb/bolt/freelist.go` (+29 -19) 📝 `vendor/github.com/boltdb/bolt/node.go` (+5 -0) 📝 `vendor/github.com/boltdb/bolt/page.go` (+31 -6) 📝 `vendor/github.com/boltdb/bolt/tx.go` (+21 -3) 📝 `vendor/vendor.json` (+9 -9) </details> ### 📄 Description This PR fixes issue #1354. > armv5 devices and older (i.e. <= arm9 generation) require addresses that are stored to and loaded from to to be 4-byte aligned. > > If this is not the case the lower 2 bits of the address are cleared and the load is performed in an unexpected order, including up to 3 bytes of data located prior to the address. > > Inlined buckets are stored after their key in a page and since there is no guarantee that the key will be of a length that is a multiple of 4, it is possible for unaligned load/stores to occur when they are cast back to bucket and page pointer types. > > The fix adds a new field to track whether the current architecture exhibits this issue, sets it on module load for ARM architectures, and then on bucket open, if this field is set and the address is unaligned, a byte-by-byte copy of the inlined bucket is performed. > The fixe commes from https://github.com/resin-os/bolt/commit/97aba5586d36f9670a77dc6e60ec1b9ef31ce9ae and has already been applied in the upstream boltdb repository https://github.com/boltdb/bolt/pull/578 I already tested this fixe on my armv5 board with success. Thanks --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-02 11:56:38 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#15875