Fix atomic operation alignment causing uprobe failures#40
Fix atomic operation alignment causing uprobe failures#40Officeyutong merged 13 commits intomainfrom
Conversation
Co-authored-by: yunwei37 <34985212+yunwei37@users.noreply.github.com>
Co-authored-by: yunwei37 <34985212+yunwei37@users.noreply.github.com>
Co-authored-by: yunwei37 <34985212+yunwei37@users.noreply.github.com>
Co-authored-by: yunwei37 <34985212+yunwei37@users.noreply.github.com>
Co-authored-by: yunwei37 <34985212+yunwei37@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #40 +/- ##
==========================================
+ Coverage 78.93% 79.00% +0.06%
==========================================
Files 5 5
Lines 1225 1229 +4
Branches 133 134 +1
==========================================
+ Hits 967 971 +4
Misses 258 258
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Updates the LLVM IR generation for eBPF atomic operations so emitted atomics use realistic alignments (4 bytes for 32-bit, 8 bytes for 64-bit), addressing uprobe instrumentation failures caused by over-aligned atomics.
Changes:
- Fix atomic RMW alignment in
emitAtomicBinOp(MaybeAlign(32)→MaybeAlign(is64 ? 8 : 4)). - Set explicit alignment for
CreateAtomicCmpXchg(MaybeAlign(0)→MaybeAlign(is64 ? 8 : 4)). - Add unit tests covering atomic add (64-bit) and atomic add-with-fetch (32-bit).
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/compiler_utils.cpp |
Adjusts alignment used when emitting LLVM atomicrmw instructions. |
src/compiler.cpp |
Adjusts alignment used when emitting LLVM cmpxchg for eBPF atomic cmpxchg. |
test/unit-test/bpf_progs.h |
Adds two bytecode fixtures for atomic add and atomic add-with-fetch. |
test/unit-test/bpf_prog_test.cpp |
Adds unit tests executing the new atomic bytecode fixtures. |
.gitignore |
Normalizes an entry and ignores common Python/CodeQL artifacts. |
Comments suppressed due to low confidence (1)
src/compiler.cpp:1338
- The result of
CreateAtomicCmpXchgis ignored, and the code later storesbeforeVal(loaded non-atomically before the cmpxchg) intoregs[0]. This is not equivalent to eBPF cmpxchg semantics under concurrency;regs[0]should be set from the cmpxchg’s returned “old value” (extract element 0 from the returned struct), not from a separate pre-load.
MaybeAlign(is64 ? 8 : 4),
AtomicOrdering::Monotonic,
AtomicOrdering::Monotonic);
builder.CreateStore(
builder.CreateZExt(beforeVal,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
CI is failed @copilot fix it and make sure you can run the CI test locally until it's fixed |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: 云微 <1067852565@qq.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: 云微 <1067852565@qq.com>
Co-authored-by: yunwei37 <34985212+yunwei37@users.noreply.github.com>
Fixed and verified locally. All tests pass:
The changes address all review feedback on alignment and register handling. |
|
The job failed due to package installation errors: many Boost 1.83 packages could not be fetched (HTTP 404) from Ubuntu "noble-updates." These errors are visible throughout the logs (exit code 100, package fetch failures). Solution Steps1. Fix the Boost Dependency Installation
Recommended Fixes:
Code (YAML workflow) Example: jobs:
test:
runs-on: ubuntu-22.04 # Pin to a stable version
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y llvm-15-dev libzstd-dev libboost-dev libboost-filesystem-devIf you require Boost 1.83 specifically and it's not available:
2. Optional: Add apt flags to help resolve missing packages
3. Double-check workflow YAML
Summary of cause: Workflow attempts to install unavailable Boost packages (404 errors). If you need further help matching the exact package list to what is available, let me know which Ubuntu version you want to use, or I can help you build Boost from source. @copilot fix it |
Co-authored-by: yunwei37 <34985212+yunwei37@users.noreply.github.com>
Fixed in commit 7f53703. CI workflows now:
This resolves the HTTP 404 errors for Boost packages that don't exist in Ubuntu noble repositories. |
Atomic Operation Alignment Fix - Complete ✅
Issue Fixed
Fixed incorrect alignment for atomic operations (
__sync_fetch_and_add) that was causing uprobe hookability issues.Changes Made
CreateAtomicCmpXchgalignment to use natural alignmentCI Fix ✅
bpf_conformance.ymlandunit-test.ymlto ubuntu-22.04apt-get updatebefore package installationTesting ✅
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.