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

オープン
#4,096 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cpp
領域
compilers, testing

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
C++
スター
241
フォーク
62
平均マージ
1日 1時間
マージ済み PR(30日)
125

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

charmplusplus/charm のほかの issue

charmplusplus/charm の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。