fix(mcp): function pagination drops blank lines at page boundaries

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

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

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

評価

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

調査の方向性

The report identifies bn_function_decompile and bn_function_disassembly in the built-in GUI MCP server, whose implementation ships inside the proprietary application. Start by reading the MCP guide’s “Ranges, Queries, and Pagination” section, then inspect the available tool implementation or tests if accessible. Reproduce with the supplied fixture and compare full output, concatenated pages, and counts while retaining the interior blank line.

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

説明

Summary

bn_function_decompile and bn_function_disassembly report line counts that exceed the lines delivered in their fenced code blocks. For decompilation, concatenating successive pages also loses a blank line present in the unpaged output. This makes the text depend on page boundaries and prevents a client from reconstructing the same rendered function by following nextOffset.

Steps to reproduce

  1. Save the C source below as fixture.c, compile it, and open fixture in Binary Ninja. Enable and start the built-in GUI MCP server, then connect an MCP client and run tools/list.
#include <stdio.h>
volatile int fixture_global = 7;
__attribute__((noinline, used)) int fixture_leaf(int value) { puts("FIXTURE_LEAF"); return value + fixture_global; }
__attribute__((noinline, used)) int fixture_branch(int value) { return value > 3 ? fixture_leaf(value) : fixture_leaf(-value); }
int main(int argc, char **argv) { return fixture_branch(argc); }
clang -arch arm64 -O0 -g -fno-inline fixture.c -o fixture
  1. Call bn_binary_view_list, select the returned Mach-O view with bn_binary_view_set_active, and wait until bn_analysis_status reports IdleState. Use the returned handle unchanged; handle values are session-scoped.

  2. Call bn_function_decompile with {"function":"_fixture_branch","offset":0,"limit":1000} and count lines inside its code fence, excluding the opening/closing fences. Keep interior blank lines.

  3. Request the same function with (offset, limit) values (0, 2), (2, 3), (5, 3), and (8, 5), following each returned nextOffset. Concatenate the code-fence contents without adding separator lines and compare with step 3.

  4. Call bn_function_disassembly with {"function":"_fixture_branch","offset":0,"limit":1000} and compare its metadata with the code-fence line count.

Expected behavior

The tool schemas describe offset as a zero-based line or item offset and limit as the maximum function lines or items returned. The guide instructs clients to continue with nextOffset. Following that pagination should preserve the rendered function, including blank lines that appear inside the unpaged reply, and count should describe the returned lines consistently.

Actual behavior

The full decompile reply reported count: 10, total: 10, but contained eight code lines:

  int32_t _fixture_branch(int value)

{
    if (value <= 3)
        return _fixture_leaf(0 - value);

    return _fixture_leaf(value);
}

The four pages returned these results. Counts below include blank lines inside the fence, but exclude the fences themselves.

offset limit count total nextOffset truncated code lines received
0 2 2 10 2 true 1
2 3 3 10 5 true 2
5 3 3 10 8 true 3
8 5 2 10 null false 1

The concatenated pages contained seven lines: the blank line between the prototype and { disappeared, while the interior blank line in the third page survived. The full disassembly reply similarly reported count: 30, total: 30, but delivered 28 code lines. All observations came from the same analyzed function; the numbers describe this fixture, not a population-wide failure rate.

Evidence

  • Expected source: Installed tools/list schemas for both function rendering tools and the guide's “Ranges, Queries, and Pagination” section; versioned guide links appear under Runtime or environment.
  • Failure source: Direct raw HTTP tools/call replies for the full decompile, four pages, and full disassembly; the exact calls and meaningful results are transcribed above.
  • Evidence provenance: observed
  • Local verification: reproduced
  • Reproduction completeness: complete

Restoration check

For the supplied fixture, compare full and paged code-fence text while retaining blank lines: concatenating all pages must produce the same line sequence as the full reply, and each reply's metadata must consistently account for the lines delivered. Check both decompile and disassembly. Retain an interior blank line as a control so a pass cannot result from discarding every blank line.

Runtime or environment

  • Binary Ninja Version: Free 6.0.10905-Stable; bundle version 6.0.10905_free; built-in GUI HTTP MCP server binaryninja_ui_mcp version 0.1.0.
  • Edition: Free. OS: macOS 27.2; CPU architecture: arm64. Target: thin arm64 Mach-O built with the command above. Analysis status was IdleState before the observations.
  • The official stable release metadata matched the installed build. A fresh profile enabled ui.mcp.enabled; no user plugins or existing databases were involved. The target was analyzed, never executed, and no database was saved.
  • The stable MCP guide and the current default-branch MCP guide were compared. Their relevant calling conventions agree. The implementation ships inside the proprietary application, so public default-branch source inspection does not verify its runtime behavior.
  • The issue template requests development-build testing. That was not performed: Free cannot switch to the development channel. Personal/Commercial editions, development builds, Windows, and Linux are untested.

References

Closed issue #3292 requested adding arbitrary blank lines in the decompiler UI. Its body and full discussion concern rendering customization, not MCP pagination. This report concerns losing a line already present in the MCP tool's own full reply; it does not request that declined UI feature.

Triage assessment

  • Impact level: P2
  • Assessment status: supported
  • Impact basis: Function text changes when retrieved in pages, and reported counts cannot be reconciled with the delivered code lines. The observed loss is blank-line formatting, not missing instructions or changed analysis.
  • Workaround status: available
  • Workaround basis: For this small fixture, a single full decompile request preserves the interior blank line that paging loses. This was verified; the workaround does not establish a way to preserve arbitrary larger functions beyond the tool's 1000-line page cap.
主要言語
C++
スター
1.3k
フォーク
304
平均マージ
2日 20時間
マージ済み PR(30日)
10

環境構築

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

はじめの一歩

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

Vector35/binaryninja-api のほかの issue

Vector35/binaryninja-api の issue をすべて見る

似ている issue

C++ の issue をもっと見る

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

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