Vector35 / binaryninja-api

Public API, examples, documentation and issues for Binary Ninja
https://binary.ninja/
MIT License
927 stars 209 forks source link

UI plugins are loaded even in headless #1556

Closed psifertex closed 1 year ago

psifertex commented 4 years ago

UI-only plugins may be loaded even in headless, though it's not normally observable without capturing logging information. Simple test case:

import binaryninja
binaryninja.log_to_stdout(binaryninja.LogLevel.WarningLog)
bv = binaryninja.BinaryViewType.get_view_of_file('/bin/ls')

produces:

Plugin module '/Applications/Binary Ninja-dev.app/Contents/Resources/python/binaryninja/../../../MacOS/plugins/libtriage.dylib' failed to load
dlerror() reports: dlopen(/Applications/Binary Ninja-dev.app/Contents/Resources/python/binaryninja/../../../MacOS/plugins/libtriage.dylib, 5): Library not loaded: @rpath/QtWidgets.framework/Versions/5/QtWidgets
  Referenced from: /Applications/Binary Ninja-dev.app/Contents/MacOS/plugins/libtriage.dylib
  Reason: image not found
list index out of range
Could not initialize UI, using headless mode only
psifertex commented 4 years ago

It's worth pointing out a very lazy but temporary fix to at least not get the message is to just re-order the log so that it happens after the core is initialized:

import binaryninja
bv = binaryninja.BinaryViewType.get_view_of_file('/bin/ls')
binaryninja.log_to_stdout(binaryninja.LogLevel.WarningLog)
melomac commented 4 years ago

May be outputing those dlopen error messages to stderr would address a few user concerns? The workaround isn't practical in my context.

melomac commented 4 years ago

Seems like it is now fixed.

jeffli678 commented 3 years ago

The reason is we do cannot distinguish a UI plugin from a core plugin until we dlopen it and see whether it exports CorePluginInit() or UIPluginInit(). But UI plugins are likely to already fail when we dlopen it, since they could import qt libs that are not present in headless

plafosse commented 1 year ago

This was fixed a while ago. Closing for now.