[Bug] Snapshot register aliases during value propagation

Aperta
#5 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
c, cpp

Direzione di ricerca

Start with RegisterValues in src/decompiler/decompiler.cpp (line 20), then assign_register around lines 427-431 and call handling around lines 586-590, where the alias "rax" is stored as a mutable name. Run the reproducer with a variadic printf call to see the recovered output diverge from the original (7 vs 0). Done means the reproducer matches after recompilation, copies keep the value from the copy point, caller-saved registers are invalidated across calls, and a regression test covers the copied return value followed by an eax setup.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Summary

Register-value propagation stores mutable register names inside expression strings. When the source register is overwritten, dependent aliases still refer to the new register value instead of the value that was copied earlier.

Evidence

src/decompiler/decompiler.cpp:20 defines RegisterValues as map<string, string>, assign_register stores the expression string at :427-431, and call handling stores the mutable alias "rax" at :586-590.

Reproducer:

#include <stdio.h>
__attribute__((noinline)) int value(void) { return 7; }
int main(void) {
    printf("%d\n", value());
    return 0;
}

The recovered code passes rax to printf after the machine code has executed mov esi, eax followed by mov eax, 0. Compiling the recovered source without treating the format warning as fatal produces:

original: 7
recovered: 0

Impact

The output can compile and run while silently changing program behavior. The same problem can affect copied arguments, values retained across calls, and caller-saved register clobbers.

Expected behavior

Register propagation should use immutable/SSA-like value nodes or otherwise snapshot the source expression at the transfer point. Writes to a source register and ABI-clobbering calls must invalidate dependent aliases.

Acceptance criteria

  • The reproducer preserves the original output after recovery and recompilation.
  • Register-to-register copies retain the value at the copy instruction, not a later value of the source register.
  • Caller-saved registers are invalidated or modeled across calls.
  • Add regression coverage for a copied return value followed by an eax setup instruction for a variadic call.
Lingua principale
C++
Stelle
0
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TiElixir/caraxes

Tutte le issue di TiElixir/caraxes

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.