Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving a binary after analysis freezes R2 #11098

Closed
afjoseph opened this issue Aug 15, 2018 · 9 comments
Closed

Saving a binary after analysis freezes R2 #11098

afjoseph opened this issue Aug 15, 2018 · 9 comments
Labels
projects Loading, saving and handling radare2 project files stale
Projects

Comments

@afjoseph
Copy link
Contributor

afjoseph commented Aug 15, 2018

Work environment

Questions Answers
OS/arch/bits (mandatory) ArchLinux / ARM 64
File format of the file you reverse (mandatory) ELF
Architecture/bits of the file (mandatory) x86/32.
r2 -v full output, not truncated (mandatory) radare2 2.9.0-git 19031 @ linux-x86-64 git.2.8.0-28-g97da424e1 commit: 97da424 build: 2018-08-10__08:41:13

Analyzing a binary in a saved project, quitting R2, and then reloading the project causes R2 to freeze. I don't really know the proper flow of handling a project, but I basically tried to follow what R2-explorations mentions: https://monosource.gitbooks.io/radare2-explorations/content/intro/projects.html

Am I doing something really funky wrong here?

Steps to reproduce the behavior

I've made a small R2R PR to reproduce the steps: https://github.com/radare/radare2-regressions/pull/1435

@Maijin Maijin added bug projects Loading, saving and handling radare2 project files labels Aug 15, 2018
@radare
Copy link
Collaborator

radare commented Aug 15, 2018 via email

@afjoseph
Copy link
Contributor Author

There you go

>>> backtrace
#0  0x00007ffff3fbf1f3 in sdb_array_contains (s=0x5555557faef0, key=0x7fffffffc1a0 "range.0x2c", val=0x7fffffffc100 "0x2ce08", cas=0x0) at array.c:511
#1  0x00007ffff3fbe447 in sdb_array_add (s=0x5555557faef0, key=0x7fffffffc1a0 "range.0x2c", val=0x7fffffffc100 "0x2ce08", cas=0) at array.c:226
#2  0x00007ffff3fbe401 in sdb_array_add_num (s=0x5555557faef0, key=0x7fffffffc1a0 "range.0x2c", val=183816, cas=0) at array.c:221
#3  0x00007ffff6501d06 in meta_inrange_add (a=0x5555557ea850, addr=183816, size=4) at meta.c:62
#4  0x00007ffff65031bc in meta_add (a=0x5555557ea850, type=116, subtype=0, from=183816, to=183820, str=0x7fffffffcc50 "0x000100af") at meta.c:382
#5  0x00007ffff650321b in r_meta_add (a=0x5555557ea850, type=116, from=183816, to=183820, str=0x7fffffffcc50 "0x000100af") at meta.c:387
#6  0x00007ffff7c421c6 in cmd_meta_others (core=0x55555575e580 <r>, input=0x555555cf3e31 "t 4 0x000100af") at cmd_meta.c:774
#7  0x00007ffff7c42b56 in cmd_meta (data=0x55555575e580 <r>, input=0x555555cf3e31 "t 4 0x000100af") at cmd_meta.c:961
#8  0x00007ffff7cc8527 in r_cmd_call (cmd=0x55555585e860, input=0x555555cf3e30 "Ct 4 0x000100af") at cmd_api.c:237
#9  0x00007ffff7c7e78a in r_core_cmd_subst_i (core=0x55555575e580 <r>, cmd=0x555555cf3e30 "Ct 4 0x000100af", colon=0x0, tmpseek=0x7fffffffd266) at cmd.c:2899
#10 0x00007ffff7c7b2ea in r_core_cmd_subst (core=0x55555575e580 <r>, cmd=0x555555cf3e30 "Ct 4 0x000100af") at cmd.c:1928
#11 0x00007ffff7c80eef in r_core_cmd (core=0x55555575e580 <r>, cstr=0x55555dbbb172 "Ct 4 0x000100af # arg3", log=0) at cmd.c:3603
#12 0x00007ffff7c81114 in r_core_cmd_lines (core=0x55555575e580 <r>, lines=0x55555daf6690 "# r2 rdb project file\n# flags\nfs symbols\nf main 4237 0x000035c0 \nf entry0 43 0x00005000 \nf entry1.init 10 0x00005100 \nf entry2.fini 50 0x000050c0 \nfs sections\nf section. 0 0x00000000 \nf section_end. 0"...) at cmd.c:3657
#13 0x00007ffff7c81273 in r_core_cmd_file (core=0x55555575e580 <r>, file=0x55555901b9c0 "/home/cheese/.local/share/radare2/projects/aaa/rc") at cmd.c:3694
#14 0x00007ffff7cdc822 in r_core_project_load (core=0x55555575e580 <r>, prjName=0x55555d9c86b3 "aaa", rcpath=0x55555901b9c0 "/home/cheese/.local/share/radare2/projects/aaa/rc") at project.c:907
#15 0x00007ffff7cdb335 in r_core_project_open (core=0x55555575e580 <r>, prjfile=0x55555d9c86b3 "aaa", thready=false) at project.c:467
#16 0x00007ffff7c159ac in cmd_project (data=0x55555575e580 <r>, input=0x55555d9c86b1 "o aaa") at cmd_project.c:78
#17 0x00007ffff7cc8527 in r_cmd_call (cmd=0x55555585e860, input=0x55555d9c86b0 "Po aaa") at cmd_api.c:237
#18 0x00007ffff7c7e78a in r_core_cmd_subst_i (core=0x55555575e580 <r>, cmd=0x55555d9c86b0 "Po aaa", colon=0x0, tmpseek=0x7fffffffd906) at cmd.c:2899
#19 0x00007ffff7c7b2ea in r_core_cmd_subst (core=0x55555575e580 <r>, cmd=0x55555d9c86b0 "Po aaa") at cmd.c:1928
#20 0x00007ffff7c80eef in r_core_cmd (core=0x55555575e580 <r>, cstr=0x55555da7e990 "Po aaa", log=1) at cmd.c:3603
#21 0x00007ffff7be8bcb in r_core_prompt_exec (r=0x55555575e580 <r>) at core.c:2465
#22 0x000055555555b682 in main (argc=2, argv=0x7fffffffddf8, envp=0x7fffffffde10) at radare2.c:1380

The sequence of command was as such:

$ gdb --args r2 /bin/ls
> aaa
> Ps hi
> Po hi 
Freeze...

I kept hitting ctrl-c to get back to gdb and then back to the execution with continue. It looks like r_meta_add() in meta.c is the culprit here.

@radare
Copy link
Collaborator

radare commented Aug 17, 2018 via email

@radare radare added this to To do in Projects Sep 21, 2018
@imyxh
Copy link
Contributor

imyxh commented Oct 6, 2018

I can reproduce this on Arch as well. Probably worth noting that I've waited for minutes on end without it loading, and radare uses 100% CPU on one core.

radare2 2.9.0 0 @ linux-x86-64 git.2.9.0
commit: HEAD build: 2018-09-05__22:48:16

@radare
Copy link
Collaborator

radare commented Oct 6, 2018 via email

@imyxh
Copy link
Contributor

imyxh commented Oct 7, 2018

This is my backtrace from running cutter in gdb and attempting to load a project:

(gdb) bt full
#0  0x00007ffff74bbef3 in ht_find_kv () at /usr/lib/libr_util.so
#1  0x00007ffff74bc286 in sdb_ht_find_kvp () at /usr/lib/libr_util.so
#2  0x00007ffff74c497d in sdb_const_get_len () at /usr/lib/libr_util.so
#3  0x00007ffff74c4b3e in sdb_const_get () at /usr/lib/libr_util.so
#4  0x00007ffff74c9cd1 in sdb_array_contains () at /usr/lib/libr_util.so
#5  0x00007ffff74c8f6c in sdb_array_add () at /usr/lib/libr_util.so
#6  0x00007ffff7b8b66f in  () at /usr/lib/libr_anal.so
#7  0x00007ffff7e6b31b in  () at /usr/lib/libr_core.so
#8  0x00007ffff7e6bde8 in  () at /usr/lib/libr_core.so
#9  0x00007ffff7ee0ca5 in r_cmd_call () at /usr/lib/libr_core.so
#10 0x00007ffff7eabee3 in  () at /usr/lib/libr_core.so
#11 0x00007ffff7e65cfd in  () at /usr/lib/libr_core.so
#12 0x00007ffff7e66348 in r_core_cmd () at /usr/lib/libr_core.so
#13 0x00007ffff7e66641 in r_core_cmd_lines () at /usr/lib/libr_core.so
#14 0x00007ffff7e667d9 in r_core_cmd_file () at /usr/lib/libr_core.so
#15 0x00007ffff7eef617 in r_core_project_load () at /usr/lib/libr_core.so
#16 0x00007ffff7eefbe6 in r_core_project_open () at /usr/lib/libr_core.so
#17 0x00007ffff7e5e4ce in  () at /usr/lib/libr_core.so
#18 0x00007ffff7ee0ca5 in r_cmd_call () at /usr/lib/libr_core.so
#19 0x00007ffff7eabee3 in  () at /usr/lib/libr_core.so
#20 0x00007ffff7e65cfd in  () at /usr/lib/libr_core.so
#21 0x00007ffff7e66348 in r_core_cmd () at /usr/lib/libr_core.so
#22 0x00007ffff7e858f0 in r_core_cmd_str () at /usr/lib/libr_core.so
#23 0x0000555555611abf in CutterCore::cmd(QString const&) ()
#24 0x000055555561780d in CutterCore::openProject(QString const&) ()
#25 0x0000555555652b77 in MainWindow::openProject(QString const&) ()
#26 0x000055555566a8af in NewFileDialog::loadProject(QString const&) ()
#27 0x000055555566a9f4 in NewFileDialog::on_loadProjectButton_clicked() ()
#28 0x0000555555716301 in NewFileDialog::qt_metacall(QMetaObject::Call, int, void**) ()
#29 0x00007ffff61d3b4d in QMetaObject::activate(QObject*, int, int, void**) () at /usr/lib/libQt5Core.so.5
#30 0x00007ffff6c0e803 in QAbstractButton::clicked(bool) () at /usr/lib/libQt5Widgets.so.5
#31 0x00007ffff6c0ea1c in  () at /usr/lib/libQt5Widgets.so.5
#32 0x00007ffff6c0fe12 in  () at /usr/lib/libQt5Widgets.so.5
#33 0x00007ffff6c0ffe6 in QAbstractButton::mouseReleaseEvent(QMouseEvent*) () at /usr/lib/libQt5Widgets.so.5
#34 0x00007ffff6b63658 in QWidget::event(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#35 0x00007ffff6b23e14 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#36 0x00007ffff6b2b92a in QApplication::notify(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#37 0x00007ffff61a9c39 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#38 0x00007ffff6b2ac11 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) ()
    at /usr/lib/libQt5Widgets.so.5
#39 0x00007ffff6b7e98c in  () at /usr/lib/libQt5Widgets.so.5
#40 0x00007ffff6b815d5 in  () at /usr/lib/libQt5Widgets.so.5
#41 0x00007ffff6b23e14 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#42 0x00007ffff6b2b6e1 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#43 0x00007ffff61a9c39 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#44 0x00007ffff65520dc in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () at /usr/lib/libQt5Gui.so.5
#45 0x00007ffff6554066 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) () at /usr/lib/libQt5Gui.so.5
#46 0x00007ffff652da3c in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Gui.so.5
#47 0x00007fffe0102e1d in  () at /usr/lib/libQt5XcbQpa.so.5
#48 0x00007ffff61a88cc in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#49 0x00007ffff61b0bc6 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5
#50 0x000055555560c875 in main ()

Fortunately the line number at the end isn't constant; if I wait a little while longer and then do another backtrace main() jumps back up to 49.

@radare
Copy link
Collaborator

radare commented Oct 7, 2018 via email

@stale
Copy link

stale bot commented Sep 6, 2020

This issue has been automatically marked as stale because it has not had recent activity. Considering a lot has changed since its creation, we kindly ask you to check again if the issue you reported is still relevant in the current version of radare2. If it is, update this issue with a comment, otherwise it will be automatically closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 6, 2020
@stale
Copy link

stale bot commented Nov 5, 2020

This issue has been automatically closed because marked as stale and it has not been updated since then. If the issue is still relevant, feel free to re-open it or open a new one.

@stale stale bot closed this as completed Nov 5, 2020
Projects automation moved this from To do to Done Nov 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
projects Loading, saving and handling radare2 project files stale
Projects
Projects
  
Done
Development

No branches or pull requests

4 participants