ci(alloc-locality): the gate cannot fail when run locally on macOS

Open Beginner friendly
#488 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@LeoBuron is already working on this.

Since Oct 29, 2026.

  • #507 by @LeoBuron — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
git, github-actions, shell
Domain
ci-cd

Research direction

Start with the alloc-locality job and the step "Reject malloc/calloc/realloc/free outside src/userApi/" in .github/workflows/ci.yml, and reproduce the bug by planting a free( call in src/ and running the git grep command locally on macOS. Replace the \b pattern with git grep -nP or an explicit boundary, and add a planted-violation self-test modeled on the other gates. Done when the gate fails on a planted violation on macOS and still passes on the clean tree on Linux CI.

Written by the indexing model from the issue text.

Description

Problem

The alloc-locality job in .github/workflows/ci.yml (step "Reject malloc/calloc/realloc/free outside src/userApi/") searches with

git grep -nE '\b(malloc|calloc|realloc|free)\s*\(' -- 'src/' 'test/' ...

On macOS (Apple Git 2.54, BSD regex), -E does not treat \b as a word boundary, so the pattern never matches. A local run of the job's script passes even with a planted free( in src/. On the Linux CI runner (GNU regex) the gate works as intended, so CI itself is not affected.

Reproduction (macOS)

mkdir -p src && printf 'void f(void){ free(p); }\n' > src/a.c
git init -q && git add -A && git -c commit.gpgsign=false commit -qm x
git grep -nE '\b(malloc|calloc|realloc|free)\s*\(' -- src/   # no match, rc=1
git grep -nP '\b(malloc|calloc|realloc|free)\s*\(' -- src/   # match, rc=0

Why it matters

Contributors run the CI gates locally (e.g. in a git copy) before pushing. For this gate a local "green" proves nothing on macOS.

Suggested fix

Use a portable pattern, e.g. git grep -nP (PCRE, same meaning on both platforms), or replace \b with an explicit boundary such as (^|[^A-Za-z0-9_])(malloc|calloc|realloc|free)[[:space:]]*\(. Add a planted-violation self-test like the other gates have, so the gate proves it can fail.

Out of scope: changing what the gate allows or forbids.

Dominant language
C
Stars
1
Forks
3
Avg merge
8h 35m
Merged PRs (30d)
18

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from es-ude/OnDeviceTraining

All issues in es-ude/OnDeviceTraining

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.