Skip to content
This repository has been archived by the owner on Feb 19, 2021. It is now read-only.

Figure out why the plugin is initialized twice #34

Closed
patateqbool opened this issue Aug 18, 2018 · 24 comments
Closed

Figure out why the plugin is initialized twice #34

patateqbool opened this issue Aug 18, 2018 · 24 comments
Assignees
Labels
bug Something isn't working

Comments

@patateqbool
Copy link
Member

The plugin is initialized twice in my case, leading to ugly hacks, we need to figured out why...
It can be noted that the plugin is initialized once if no IDB is loaded and twice if an IDB is loaded.

@patateqbool patateqbool added this to the 0.2 milestone Aug 18, 2018
@patateqbool patateqbool added the enhancement New feature or request label Aug 18, 2018
@NeatMonster NeatMonster added bug Something isn't working and removed enhancement New feature or request labels Aug 18, 2018
@NeatMonster NeatMonster changed the title Figured out why the plugin is initialized twice Figure out why the plugin is initialized twice Aug 19, 2018
@NeatMonster
Copy link
Member

NeatMonster commented Aug 19, 2018

On my Linux machine, init() is only called once, whether or not I open a database. Same goes with my Windows VM. I tested by writing to a file within init() to make sure I didn't miss any debug output.

@NeatMonster NeatMonster added invalid This doesn't seem right and removed bug Something isn't working labels Aug 20, 2018
@NeatMonster
Copy link
Member

@patateqbool Could you remove your "ugly hacks" in your next commit and close this issue? Thanks!

@NeatMonster NeatMonster removed this from the 0.2 milestone Aug 20, 2018
@patateqbool patateqbool added bug Something isn't working and removed invalid This doesn't seem right labels Aug 20, 2018
@patateqbool
Copy link
Member Author

No I can't because.... This is a bug ! Mouahahahahah \o>

@patateqbool
Copy link
Member Author

The previous fix seems to crash IDA in some cases.
Here are the steps to reproduce in order to reach the bug:

  • cp /bin/ls /tmp
  • open /tmp/ls with ida and close to create /tmp/ls.i64
  • cp /tmp/ls.i64 /tmp/ls2.i64
  • ida64 /tmp/ls.i64 & ida64 /tmp/ls2.i64
    Open first /tmp/ls2.i64 and then /tmp/ls.i64, the first one should open correctly and the second one should crash.
    @NeatMonster can you check this out ? Thanks !

@NeatMonster
Copy link
Member

NeatMonster commented Aug 23, 2018

(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00007f4c9ba8d02e in py_call_nav_colorizer (nbytes=<optimized out>, ea=18446744073709551615, 
    col=<optimized out>) at obj/x64_linux_gcc_64_opt/wrappers/kernwin.cpp:5023
#2  _wrap_call_nav_colorizer (args=<optimized out>) at obj/x64_linux_gcc_64_opt/wrappers/kernwin.cpp:13904
#3  0x00007f4ca03a07e4 in PyEval_EvalFrameEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#4  0x00007f4ca04cab88 in PyEval_EvalCodeEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#5  0x00007f4ca039f580 in PyEval_EvalFrameEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#6  0x00007f4ca04cab88 in PyEval_EvalCodeEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#7  0x00007f4ca0480c59 in ?? () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#8  0x00007f4ca03403c3 in PyObject_Call () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#9  0x00007f4ca049784c in ?? () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#10 0x00007f4ca03403c3 in PyObject_Call () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#11 0x00007f4ca0340531 in PyObject_CallFunction () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#12 0x00007f4c9ba5d8a9 in lambda_t::call_py_colorizer (ea=18446744073709551615, nbytes=0)
    at obj/x64_linux_gcc_64_opt/wrappers/kernwin.cpp:4978
#13 0x00005627bd35ad4d in ?? ()
#14 0x00005627bd35bd69 in ?? ()
#15 0x00007f4caa32ca24 in QT::QApplicationPrivate::notify_helper(QT::QObject*, QT::QEvent*) ()
   from /home/neat/ida-7.1/libQt5Widgets.so.5
#16 0x00007f4caa32c84f in QT::QApplication::notify(QT::QObject*, QT::QEvent*) ()
   from /home/neat/ida-7.1/libQt5Widgets.so.5
#17 0x00005627bd1a4509 in ?? ()
#18 0x00007f4ca95bd1e4 in QT::QCoreApplication::notifyInternal2(QT::QObject*, QT::QEvent*) ()
   from /home/neat/ida-7.1/libQt5Core.so.5
#19 0x00007f4ca95c127c in QT::QCoreApplication::sendEvent(QT::QObject*, QT::QEvent*) ()
   from /home/neat/ida-7.1/libQt5Core.so.5
#20 0x00007f4ca95be5c7 in QT::QCoreApplicationPrivate::sendPostedEvents(QT::QObject*, int, QT::QThreadData*) ()
   from /home/neat/ida-7.1/libQt5Core.so.5
---Type <return> to continue, or q <return> to quit---

Sounds like it is related to the navbar colorizer. ;-)

@NeatMonster
Copy link
Member

gef➤  bt
#0  0x00007fde8c1b0e7f in sipSubClass_QApplication () at /home/patate/ida-7.1/python/PyQt5/QtWidgets.so
#1  0x00007fde8d080bd8 in  () at /home/patate/ida-7.1/python/lib/python2.7/lib-dynload/sip.so
#2  0x00007fde8d084b2b in  () at /home/patate/ida-7.1/python/lib/python2.7/lib-dynload/sip.so
#3  0x00007fde8c177f59 in convertFrom_QList_0101QWidget () at /home/patate/ida-7.1/python/PyQt5/QtWidgets.so
#4  0x00007fde8d08c689 in  () at /home/patate/ida-7.1/python/lib/python2.7/lib-dynload/sip.so
#5  0x00007fde8c029f76 in meth_QApplication_topLevelWidgets () at /home/patate/ida-7.1/python/PyQt5/QtWidgets.so
#6  0x00007fde9acfe3a9 in PyEval_EvalFrameEx () at /usr/lib/libpython2.7.so.1.0
#7  0x00007fde9acfe9d0 in PyEval_EvalFrameEx () at /usr/lib/libpython2.7.so.1.0
#8  0x00007fde9ad590da in PyEval_EvalCodeEx () at /usr/lib/libpython2.7.so.1.0
#9  0x00007fde9aceae0f in function_call.lto_priv () at /usr/lib/libpython2.7.so.1.0
#10 0x00007fde9aca20e3 in PyObject_Call () at /usr/lib/libpython2.7.so.1.0
#11 0x00007fde9ad0e49f in instancemethod_call.lto_priv () at /usr/lib/libpython2.7.so.1.0
#12 0x00007fde9aca20e3 in PyObject_Call () at /usr/lib/libpython2.7.so.1.0
#13 0x00007fde9ad46de4 in slot_tp_init.lto_priv () at /usr/lib/libpython2.7.so.1.0
#14 0x00007fde9acc02c5 in type_call.lto_priv () at /usr/lib/libpython2.7.so.1.0
#15 0x00007fde9aca20e3 in PyObject_Call () at /usr/lib/libpython2.7.so.1.0
#16 0x00007fde9ad0380e in PyEval_EvalFrameEx () at /usr/lib/libpython2.7.so.1.0
#17 0x00007fde9ad590da in PyEval_EvalCodeEx () at /usr/lib/libpython2.7.so.1.0
#18 0x00007fde9aceae0f in function_call.lto_priv () at /usr/lib/libpython2.7.so.1.0
#19 0x00007fde9aca20e3 in PyObject_Call () at /usr/lib/libpython2.7.so.1.0
#20 0x00007fde9ad0e49f in instancemethod_call.lto_priv () at /usr/lib/libpython2.7.so.1.0

@patateqbool
Copy link
Member Author

patateqbool commented Aug 23, 2018

Still not working on my side:

gef➤  bt
#0  0x0000000000000000 in  ()
#1  0x00007f8c39bdfe82 in sipSubClass_QApplication () at /home/patate/ida-7.1/python/PyQt5/QtWidgets.so
#2  0x00007f8c3aaafbd8 in  () at /home/patate/ida-7.1/python/lib/python2.7/lib-dynload/sip.so
#3  0x00007f8c3aab3b2b in  () at /home/patate/ida-7.1/python/lib/python2.7/lib-dynload/sip.so
#4  0x00007f8c39ba6f59 in convertFrom_QList_0101QWidget () at /home/patate/ida-7.1/python/PyQt5/QtWidgets.so
#5  0x00007f8c3aabb689 in  () at /home/patate/ida-7.1/python/lib/python2.7/lib-dynload/sip.so
#6  0x00007f8c39a58f76 in meth_QApplication_topLevelWidgets () at /home/patate/ida-7.1/python/PyQt5/QtWidgets.so
#7  0x00007f8c4c8a43a9 in PyEval_EvalFrameEx () at /usr/lib/libpython2.7.so.1.0
#8  0x00007f8c4c8a49d0 in PyEval_EvalFrameEx () at /usr/lib/libpython2.7.so.1.0
#9  0x00007f8c4c8a49d0 in PyEval_EvalFrameEx () at /usr/lib/libpython2.7.so.1.0
#10 0x00007f8c4c8a49d0 in PyEval_EvalFrameEx () at /usr/lib/libpython2.7.so.1.0
#11 0x00007f8c4c8a49d0 in PyEval_EvalFrameEx () at /usr/lib/libpython2.7.so.1.0
#12 0x00007f8c4c8ff0da in PyEval_EvalCodeEx () at /usr/lib/libpython2.7.so.1.0
#13 0x00007f8c4c890e0f in function_call.lto_priv () at /usr/lib/libpython2.7.so.1.0
#14 0x00007f8c4c8480e3 in PyObject_Call () at /usr/lib/libpython2.7.so.1.0
#15 0x00007f8c4c8b449f in instancemethod_call.lto_priv () at /usr/lib/libpython2.7.so.1.0
#16 0x00007f8c4c8480e3 in PyObject_Call () at /usr/lib/libpython2.7.so.1.0
#17 0x00007f8c4c8fe7d1 in PyEval_CallObjectWithKeywords () at /usr/lib/libpython2.7.so.1.0
#18 0x00007f8c4cc457a1 in  () at /home/patate/ida-7.1/plugins/python64.so
#19 0x00007f8c5664219b in  () at /home/patate/ida-7.1/libida64.so
#20 0x00007f8c56646669 in init_plugins () at /home/patate/ida-7.1/libida64.so
#21 0x000055f9cab0aedb in  ()
#22 0x000055f9cab0b95a in  ()
#23 0x000055f9cab0c3a3 in  ()
#24 0x000055f9caaf334a in  ()
#25 0x00007f8c53c8e06b in __libc_start_main () at /usr/lib/libc.so.6
#26 0x000055f9caaf87dd in  ()
#27 0x00007ffeb3429e18 in  ()
#28 0x000000000000001c in  ()
#29 0x0000000000000002 in  ()
#30 0x00007ffeb342a5f4 in  ()
#31 0x00007ffeb342a60f in  ()
#32 0x0000000000000000 in  ()

@NeatMonster
Copy link
Member

@patateqbool Could you check again after commit 979bf7c?

@NyaMisty
Copy link
Contributor

After 979bf7c I can't even run the plugin hahah

@NeatMonster
Copy link
Member

@NyaMisty Oops, should be fixed by @SilverBut 's commit (d8a95b4).

@patateqbool
Copy link
Member Author

I'm currently at 4331e5d and I still have crashes :(
Here the backtrace

#1  0x00007fd41f737bd8 in  () at /home/patate/ida-7.1/python/lib/python2.7/lib-dynload/sip.so
#2  0x00007fd41f73bb2b in  () at /home/patate/ida-7.1/python/lib/python2.7/lib-dynload/sip.so
#3  0x00007fd41ee3df59 in convertFrom_QList_0101QWidget () at /home/patate/ida-7.1/python/PyQt5/QtWidgets.so
#4  0x00007fd41f743689 in  () at /home/patate/ida-7.1/python/lib/python2.7/lib-dynload/sip.so
#5  0x00007fd41eceff76 in meth_QApplication_topLevelWidgets () at /home/patate/ida-7.1/python/PyQt5/QtWidgets.so
#6  0x00007fd431ab13a9 in PyEval_EvalFrameEx () at /usr/lib/libpython2.7.so.1.0
#7  0x00007fd431ab19d0 in PyEval_EvalFrameEx () at /usr/lib/libpython2.7.so.1.0
#8  0x00007fd431b0c0da in PyEval_EvalCodeEx () at /usr/lib/libpython2.7.so.1.0
#9  0x00007fd431a9de0f in function_call.lto_priv () at /usr/lib/libpython2.7.so.1.0
#10 0x00007fd431a550e3 in PyObject_Call () at /usr/lib/libpython2.7.so.1.0
#11 0x00007fd431ac149f in instancemethod_call.lto_priv () at /usr/lib/libpython2.7.so.1.0
#12 0x00007fd431a550e3 in PyObject_Call () at /usr/lib/libpython2.7.so.1.0
#13 0x00007fd431af9de4 in slot_tp_init.lto_priv () at /usr/lib/libpython2.7.so.1.0
#14 0x00007fd431a732c5 in type_call.lto_priv () at /usr/lib/libpython2.7.so.1.0
#15 0x00007fd431a550e3 in PyObject_Call () at /usr/lib/libpython2.7.so.1.0
#16 0x00007fd431ab680e in PyEval_EvalFrameEx () at /usr/lib/libpython2.7.so.1.0
#17 0x00007fd431b0c0da in PyEval_EvalCodeEx () at /usr/lib/libpython2.7.so.1.0
#18 0x00007fd431a9de0f in function_call.lto_priv () at /usr/lib/libpython2.7.so.1.0
#19 0x00007fd431a550e3 in PyObject_Call () at /usr/lib/libpython2.7.so.1.0
#20 0x00007fd431ac149f in instancemethod_call.lto_priv () at /usr/lib/libpython2.7.so.1.0
#21 0x00007fd431a550e3 in PyObject_Call () at /usr/lib/libpython2.7.so.1.0
#22 0x00007fd431af9de4 in slot_tp_init.lto_priv () at /usr/lib/libpython2.7.so.1.0
#23 0x00007fd431a732c5 in type_call.lto_priv () at /usr/lib/libpython2.7.so.1.0
#24 0x00007fd431a550e3 in PyObject_Call () at /usr/lib/libpython2.7.so.1.0
#25 0x00007fd431ab680e in PyEval_EvalFrameEx () at /usr/lib/libpython2.7.so.1.0
#26 0x00007fd431b0c0da in PyEval_EvalCodeEx () at /usr/lib/libpython2.7.so.1.0
#27 0x00007fd431e51a71 in  () at /home/patate/ida-7.1/plugins/python64.so
#28 0x00007fd43b84fb3a in  () at /home/patate/ida-7.1/libida64.so
#29 0x00007fd43b853669 in init_plugins () at /home/patate/ida-7.1/libida64.so
#30 0x0000562c04f22edb in  ()
#31 0x0000562c04f2395a in  ()
#32 0x0000562c04f243a3 in  ()
#33 0x0000562c04f0b34a in  ()
#34 0x00007fd438e9b06b in __libc_start_main () at /usr/lib/libc.so.6
#35 0x0000562c04f107dd in  ()
#36 0x00007ffc5837a218 in  ()
#37 0x000000000000001c in  ()
#38 0x0000000000000002 in  ()
#39 0x00007ffc5837b5f0 in  ()
#40 0x00007ffc5837b60b in  ()
#41 0x0000000000000000 in  ()

@patateqbool patateqbool reopened this Aug 24, 2018
@patateqbool
Copy link
Member Author

In addition, the latest commit introduced these messages when closing IDA

QLayout: Attempting to add QLayout "" to QWidget "", which already has a layout

@NeatMonster
Copy link
Member

@patateqbool What's the status on this issue? Still occurring?

@patateqbool
Copy link
Member Author

Currently working on macOS. I'll tell you when I go back under my workflow which generates the problems.

@SilverBut
Copy link
Contributor

I can partially reproduce it in latest commit 1d345cc, using IDA 7.1 Linux.

However I don't think the plugin is loaded twice, since if you do this patch in idarling/inferface/plugin.py you can see while the initialize message and get me out message print out 2 times, the message already out only output 1 time.

Maybe someone wrongly used logging?

deepinscreenshot_select-area_20180828220913

Patch:

diff --git a/idarling/plugin.py b/idarling/plugin.py
index 648bb88..3ea62a1 100644
--- a/idarling/plugin.py
+++ b/idarling/plugin.py
@@ -147,6 +147,8 @@ class Plugin(ida_idaapi.plugin_t):
         """
         Print the banner into the console.
         """
+        logger.info("GET ME OUT!")
+        print("Already out.")
         copyright = "(c) %s" % self.PLUGIN_AUTHORS
 
         logger.info("-" * 75)

@NeatMonster
Copy link
Member

NeatMonster commented Aug 28, 2018

@SilverBut Are you taking about this crash? I've found that the __init__ method from the plugin class is called twice if you're opening an IDB, but that init and term methods are only called once. But that shouldn't be an issue because all the real initialization stuff should be performed within init.

However, @patateqbool and I have been using this ticket to track other unrelated crashes (e.g. the backtraces), when we should have opened new issues instead. Sorry about that...

@SilverBut
Copy link
Contributor

Alright I see...

@SilverBut
Copy link
Contributor

@patateqbool

By the way, this comment

In addition, the latest commit introduced these messages when closing IDA

QLayout: Attempting to add QLayout "" to QWidget "", which already has a layout

Has now been resolved (but not comitted yet).

@patateqbool
Copy link
Member Author

@SilverBut ack, thank you.

@NeatMonster
Copy link
Member

@SilverBut I believed it is fixed in the master branch.

The layout of the network settings tab was being added to self instead of tab.

@SilverBut
Copy link
Contributor

@SilverBut I believed it is fixed in the master branch.

@NeatMonster At least not in commit 1d345cc for IDA 7.1 under Linux. You can still see those hints when opening the "settings" dialog.

@NeatMonster
Copy link
Member

@SilverBut That's weird. I don't see them with the exact same setup.

@NeatMonster
Copy link
Member

QLayout: Attempting to add QLayout "" to QWidget "", which already has a layout

@patateqbool Could you check if the message is gone after the recent changes? Have you encountered another crash of IDA since to QCoreApplication to qApp change?

@patateqbool
Copy link
Member Author

@NeatMonster nop, it's fine now. I don't have crash anymore too. :) I think we can close this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants