charmxi segfaults on a declared CkMigrateMessage constructor entry (null member in AST, isTramTarget)

Aperta
#4,096 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
compilers, testing

Direzione di ricerca

Read the constructor entry rule near the warning in src/xlat-i/xi-grammar.y, then trace how it adds members to the AST and how isTramTarget() traverses them in src/xlat-i/xi-AstNode.h. Reproduce with the supplied interface and add a regression test under tests/charm++/charmxi_parsing; done means charmxi no longer segfaults on the declared migration constructor and the test passes.

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

Descrizione

Bug

Summary

charmxi segfaults on an interface file that declares a migration constructor as an entry method, right after printing the warning that such a constructor is taken for granted. Reproduces on recharm (4ad7320be, reconverse-darwin-arm8) and on a classic netlrts-darwin-arm8-smp build.

Reproducer

mainmodule Y {
  array [1D] Cell {
    entry Cell();
    entry Cell(CkMigrateMessage* m);
  };
};
$ charmxi Y.ci
Y.ci:4:5-36: warning: CkMigrateMsg chare constructor is taken for granted
...
Segmentation fault (exit 139)

Backtrace (lldb): EXC_BAD_ACCESS address=0x0 in xi::AstChildren<xi::Member>::isTramTarget().

Cause

The grammar rule for a constructor entry (src/xlat-i/xi-grammar.y, the ENTRY Name EParameters ... alternative near the warning) sets $$ = NULL after warning, so the chare's member list contains a null Member*. The traversals written since then guard against that (genGlobalCode, genTramPups in src/xlat-i/xi-AstNode.h test if (*i)), but AstChildren<Child>::isTramTarget() (added with [aggregate] support in 1225c6d78, 2017) dereferences every child without the check. The warning itself dates from 2015, so declaring the migration constructor has crashed charmxi since 2017 rather than being tolerated as the warning implies.

Two secondary defects in the same rule: the warning is attributed to the wrong line (the next entry's line when one follows, since lineno has already advanced past the semicolon), and the entry is dropped instead of being accepted with a warning, which is why old code and tutorials that declare entry X(CkMigrateMessage*) only work when nothing else in the module triggers the TRAM scan.

Suggested fix

Either do not push the null into the member list (accept the entry and ignore it in code generation, or drop it at the point the list is built), or add the if (*i) guard to isTramTarget() as in the other traversals. The first is better: a null child in the AST is what every later traversal has to work around. A regression test belongs in tests/charm++/charmxi_parsing (added by #4027).

Found while evaluating an external translator that emits this declaration; not specific to that tool.

Lingua principale
C++
Stelle
241
Fork
62
Merge medio
1g 1h
PR unite (30g)
121

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 charmplusplus/charm

Tutte le issue di charmplusplus/charm

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.