Vector35 / Vector35/binaryninja-api
Document which operations which are only safe to be performed on the main thread
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.3k
- Forks
- 298
- Avg merge
- 5d 5h
- Merged PRs (30d)
- 19
Description
Discussed in https://github.com/Vector35/binaryninja-api/discussions/3759
Originally posted by cxiao December 27, 2022
In the Python API, the mainthread module and several classes in the plugin module offer functionality for performing work on background threads, as well as functionality for ensuring that certain operations are only run on the main thread (e.g. mainthread.execute_on_main_thread.
However, it is not clear what types of operations can only ever be safely executed on the main thread. The one I can think of immediately is operations that update the UI, but are there any others? For example:
- Is it safe to update settings (regardless of whether they are user, project, or resource scope) from a background thread?
- Is it safe to perform file operations on the underlying BNDB via the functionality exposed by
filemetadata.FileMetadatafrom a background thread?
In IDA, the IDA C++ SDK has the THREAD_SAFE keyword, which has the following description:
#define THREAD_SAFE
Functions callable from any thread are marked with this keyword.
As of IDA 7.2, IDAPython enforces the following behaviour for functions not marked with this keyword:
IDAPython: all functions not marked as THREAD_SAFE in the C++ SDK, will now check that they are being called from the main thread, avoiding possible corruption or crashes
Does the Binary Ninja core already enforce that certain functions can only ever be called from the main thread, and if so is it possible to expose information about that in the API docs?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the Python API mainthread and plugin modules, along with FileMetadata operations and the referenced discussion. Determine which operations are restricted to the main thread and whether the core exposes that information. Done means the relevant thread-safety behavior is clearly documented in the API documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100