LouisBrunner / LouisBrunner/valgrind-macos

offsetB assert in genSpill_ARM64

Open
#197 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
1.4k
Forks
72
Avg merge
6h 40m
Merged PRs (30d)
1

Description

### Context

Running a large program results in a valgrind assert

#### What went wrong?

When running the program it hits the following assert:
vex: priv/host_arm64_defs.c:2836 (void genSpill_ARM64(HInstr **, HInstr **, HReg, Int, Bool)): Assertion `offsetB < 4096' failed.
Command run is just plain "valgrind".

To my best understanding, while the spill area itself is only 4096 bytes there is an additional offset involved, meaning offsetB can become larger than 4096.
Best I can tell the simplest fix should be to change ARM64Instr_VLdStQ to use ldr/str instead of ld1.2d/st1.2d, since the former supports a 12-bit offset.
This both avoids the need for the extra add in HRcVec128 and increases the range to 64k.

### Information

* macOS architecture (`uname -m`): arm64
* macOS version (`sw_vers`): 26.5.1
* Xcode version (`xcrun --sdk macosx --show-sdk-version`): 26.5

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in priv/host_arm64_defs.c at genSpill_ARM64 and inspect ARM64Instr_VLdStQ and HRcVec128, then reproduce the assertion with the reported large program under plain valgrind. Compare the offset handling with the proposed ldr/str approach. Done means the ARM64 run no longer triggers the offsetB assertion for the reported case.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, macos
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.