isValidUtf8 faults with SIGBUS on 32-bit ARM: read_uint64 takes a uint64_t pointer
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- backend, performance
Research direction
Start in cbits/is-valid-utf8.c and inspect read_uint64 plus the calls at the locations described in the issue. Reproduce the failure with the reported ARMv7 setup if available, then verify the pointer type and call arguments no longer imply alignment. Done when UTF-8 validation no longer faults on an unaligned pointer and the relevant tests pass.
Written by the indexing model from the issue text.
Description
cbits/is-valid-utf8.c reads 8-byte blocks with read_uint64(const uint64_t *p), and the callers pass (uint64_t const *)ptr with ptr at any byte offset (lines 64 and 109-117 on master). The pointer type tells the compiler the address is 8-byte aligned, so on ARMv7 clang compiles the memcpy in read_uint64 to ldrd, which faults on an address that is not 4-byte aligned. The fix for #475 replaced the plain loads with memcpy but kept the pointer type.
Observed with GHC 9.14.1 (bytestring 0.12.2.0) cross-compiling for armv7a Android: Template Haskell under qemu stopped with qemu: uncaught target signal 7 (Bus error) in text 2.1.3's UTF-8 validation, which calls this function, with a pointer one byte past an ASCII byte.
Fix: read_uint64 takes uint8_t const *, and the calls pass ptr, ptr + 8, ptr + 16, ptr + 24. The patch we apply in our haskell.nix fork: https://github.com/simplex-chat/haskell.nix/pull/4
- Dominant language
- Haskell
- Stars
- 302
- Forks
- 146
- Avg merge
- 7d 21h
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from haskell/bytestring
-
Difficulty 1/5 Under an hour Newbie friendliness 35/100
haskell/bytestring#723 · 2 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
haskell/bytestring#697 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
haskell/bytestring#689 · 2 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
haskell/bytestring#684 · 3 comments ·
-
Fixed Point RoundingOpen
Difficulty 5/5 Over a week Newbie friendliness 25/100
haskell/bytestring#679 · 2 comments ·
All issues in haskell/bytestring
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
seal-harness/seal-harness#399 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
fmidue/codeworld-tasks#124 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
reflex-frp/reflex#563 ·
-
The codecov job never gets a runner on macos-26 and is cancelledPossibly taken @yegor256 claimed this 1 day ago. Openbug
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
objectionary/phino#2524 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
IntersectMBO/cardano-api#1434 ·
Maintainers usually reply within 2 days