fix(nft): the per-batch markersAdded() call is not guarded against re-entry

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

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

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
cpp
領域
backend

調査の方向性

Start with NFTDetector.h and the per-batch markersAdded() call at the end of addNFTMarkers(); compare it with the guarded calls in ensureDetector() and the creation backfill. Then add tests for a second batch whose callback calls teardown() and addNFTMarkers(). Decide and document the outcome for already committed markers, and verify that nested calls are refused and the detector remains alive until its callback returns.

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

説明

NFTDetector.h says that a call back into the core from markersAdded() is refused before it changes anything, and that the outer addNFTMarkers() / setupAR2() fails. That holds for the calls made from ensureDetector(), the backfill at creation, which runs under CreatingGuard. But the per-batch call at the end of addNFTMarkers() runs outside the guard:

if (batchSize > 0 && this->detector) {
  this->detector->markersAdded(markerIds, datasetPathnames);
}

From there, teardown(), setupAR2() or setCamera() is not refused. It destroys the detector while its markersAdded() is still running, which is undefined behaviour. addNFTMarkers() recurses.

Found by Qodo on #129. Introduced by #116; #124 added the guard for the creation path only. It only shows with a detector that breaks the documented contract, so it does not block 0.13.0.

To decide

When the per-batch call runs, the batch is already committed: ids are assigned and the KPM reference data is set. Returning {} at that point would report a failure for markers that are loaded. Options:

  • refuse the nested call, discard the detector, log, and still return the ids, so the next setupAR2() recreates the detector; update NFTDetector.h to say so;
  • or notify before committing, and roll back if the detector re-entered.

Fix sketch

Share the RAII guard of ensureDetector() with the per-batch call. Afterwards, check creationReentered and whether the detector or the handles changed.

Test

A second batch whose markersAdded() calls teardown(), and separately addNFTMarkers(). The nested call must be refused, the detector must stay alive until its callback returns, and the outcome must match the chosen contract.

主要言語
C++
スター
21
フォーク
8
平均マージ
3時間 42分
マージ済み PR(30日)
22

環境構築

はじめの一歩

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

webarkit/WebARKitLib のほかの issue

webarkit/WebARKitLib の issue をすべて見る

似ている issue

C++ の issue をもっと見る

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

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