freestanding_check: hosted-RNG check misses rand/srand in headers, macro aliases and function pointers

Abierto
#2,309 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
c, shell

Línea de trabajo

Start in tools/freestanding_check.sh, where the hosted-RNG stage greps src/.c and extensions/.c for rand( and srand(), and read tools/freestanding_allowlist.txt to see why stage 1 passes. The proposed fix replaces the textual check with an nm -u scan of the hosted objects built by the gate's rows, so the design needs deciding first. Done when the four planted cases (static inline in a header, macro alias, function pointer, untracked file) make make freestanding-check exit nonzero, and src/freestanding/ stays green.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

area:gates kind:gate-defect

The hosted-RNG half of tools/freestanding_check.sh (#1818; fail-closed fix in the PR for #2308) searches only tracked src/*.c and extensions/*.c, outside src/freestanding/, for the literal spelling rand( / srand(. The following reach libc rand/srand from hosted runtime code without being seen:

  1. A call inside a static inline function, or a macro body, in a header (src/*.h, extensions/*.h).
  2. A call through a macro alias, e.g. #define RNG rand and then RNG(), or through a function pointer (int (*r)(void) = rand;).
  3. Untracked files. git grep searches the index, so a new file that has not been git added is skipped in a local run. CI only sees committed files, so this matters only locally.

Stage 1 cannot catch any of these, because rand/srand are in tools/freestanding_allowlist.txt.

Possible root fix: check the symbol level instead of the spelling. Every hosted object built by the gate's rows would have no undefined reference to rand/srand (nm -u over the objects that are not freestanding), so headers, macros and pointers are all covered. The textual grep could stay as a fast first pass.

Found while reviewing the hq#58 fix (https://github.com/InauguralSystems/hq/issues/58).

Done when
  • A planted static inline int r(void) { return rand(); } in a header that a runtime .c file includes and calls makes make freestanding-check exit nonzero.
  • A planted #define RNG rand plus RNG() in src/*.c makes it exit nonzero.
  • A planted int (*p)(void) = rand; in src/*.c makes it exit nonzero.
  • src/freestanding/ keeps its own rand implementation, and that case is still green.

Generated by Claude Code

Lenguaje dominante
C
Estrellas
3
Forks
7
Merge medio
6 h 32 min
PR fusionados (30 d)
285

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de InauguralSystems/EigenScript

Todos los issues de InauguralSystems/EigenScript

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.