Repository navigation
Fetch a match's remote function off the UI thread - #40
Conversation
Double clicking a function match, a name's function id or a block match
downloaded the remote function with its CFG and then its sample entry,
on the UI thread, before matching it and opening its graph. For the
largest function of a 2,329-function sample (3,955 instructions) against
mcrit.malpedia.io that froze Binary Ninja for about 3.5 s: 2.2 s for the
function, 1.3 s for the sample entry, 0.1 s for the matcher.
McritInterface.queryRemoteFunction fetches both and touches no widget.
The three handlers run it through Backend.run_request and match and
draw when the answer arrives. The sample entry comes from the sample
list already downloaded when it has it, which saves the second request.
On IDA, run_request still runs synchronously, so IDA blocks as before,
minus that request.
Double clicking that match in Binary Ninja 6.0, three times each:
before after
click returns after 3.36-3.58 s 0.00 s
graph opens after 3.32-3.54 s 2.07-2.20 s
longest UI stall 3.36-3.58 s 0.11-0.12 s
The Binary Ninja GUI test waits for each of the three graphs and checks
that the click returns before the graph opens and that the remote
function is fetched off the UI thread.
40b756b to
03b3ece
Compare
# Conflicts: # mcrit_plugin/ui_qt/widgets/FunctionMatchWidget.py
danielplohmann
left a comment
There was a problem hiding this comment.
Thanks, this looks good. The worker touches no widget, and the callbacks keep the local function and the block matches from the click, so a cursor move during the fetch cannot mix up the graph. Both calls pass the title #35 added, and IDA's synchronous path still opens the graph from the callback. Reading sample_infos from the worker is safe, since it is only ever replaced, never changed in place.
It merges into main without conflicts. Lint, the sync checks and the suite (229 tests) pass on the merged tree, and the new queryRemoteFunction tests fail without the change. I could not run the Binary Ninja or IDA integration tests.
A few small points, none blocking:
- After a successful fetch the activity line still says "Fetching function N for the graph viewer...".
show()could replace it when the graph opens. - On a failed request,
_reportFailureposts the reason and "Failed to fetch function entry N." then overwrites it. That was already so before, but it would be easy to keep the reason now. - A second double-click on the same row while the first fetch runs opens two identical graphs. Ignoring a repeat for a function already being fetched would avoid that.
- The changelog entry could say that on IDA the click still blocks, minus the sample request.
The approval will only count after main is merged in, since #35 moved the merge-base.
The merge-base changed after approval.
# Conflicts: # CHANGELOG.md
danielplohmann
left a comment
There was a problem hiding this comment.
Thanks. The merge of main (6657f1e) keeps every changelog bullet. Lint, the sync checks and the suite (232 tests) pass on it. Approving again; the earlier small points stay optional.
|
#37 is merged, so this needs |
# Conflicts: # CHANGELOG.md
danielplohmann
left a comment
There was a problem hiding this comment.
Thanks. The merge of main (1a33418) keeps every changelog bullet. Lint, the sync checks and the suite (240 tests) pass on it. Approving again.
This builds on #35, which builds on #33 and #31; the diff shows their commits until they merge, and only 03b3ece is new. It was rebased onto #35 so that the remote-function request passes the title #35 gives
Backend.run_request; on #31 alone, merging #35 afterwards left this request calling it with two arguments, and opening a match's graph raisedTypeErroron both plugins. #36 builds on this PR and applies its local tint in the callback that runs when the remote function arrives.Double clicking a function match, a function id in the names table, or a block match opens the remote function's graph. Before it could, the handler downloaded that function with its CFG and then the entry of its sample, both on the UI thread. The table below breaks that down for the largest function of sample
e0b6f853…(3,955 instructions, 1,361 blocks), whose match on mcrit.malpedia.io is a function of the same size:getFunctionById(…, with_xcfg=True)getSampleByIdtoSmdaFunctionFunctionCfgMatcher.getColoredMatchesThe network calls are almost all of it.
McritInterface.queryRemoteFunctionnow fetches the function and its sample and touches no widget. The three handlers run it throughBackend.run_request, then match and draw when the answer arrives. The sample entry comes from the sample list the plugin already downloaded during Convert, and only a sample missing from it is requested.Double clicking that match in Binary Ninja 6.0 against mcrit.malpedia.io, three times each:
On IDA,
run_requeststill runs synchronously, so the double click blocks as before, minus the sample request when the sample list is loaded.tests/core/test_mcrit_interface.pycoversqueryRemoteFunctionin three cases:None.The Binary Ninja GUI test now waits for each of the three graphs. It checks that the click returns before the graph opens and that the remote function is fetched off the UI thread. Against a local MCRIT 1.12.0 it passes all 179 checks.
pytestgives 214 passed, andrun_quality_checks.pyand the sync checks pass. The IDA tests were not run.