radareorg/iaito

Segmentation fault opening main iaito window (M1 Mac, macOS 12)

Closed this issue · 17 comments

Environment Details

QCommandLineParser: already having an option named "w"
iaito 5.5.0
Sun Feb  6 15:24:56 CET 2022
radare2 5.6.0 27361 @ darwin-arm-64 git.5.6.0
commit: e9e600a9a4c22a1e4aa901ab50e1d744648bd722 build: 2022-02-06__13:47:14
Darwin arm64

Description

Iaito crashes (seg fault) after pressing start on the file selection dialog. It doesn't matter if I select a file or check "don't open any file". Installed r2 from source successfully (and fully working).

Following was used to build iaito:

brew install qmake qt@5
brew link --force qt@5
git clone https://github.com/radareorg/iaito.git
cd iaito
./configure
make -j8
make run #or make install

Following is the lldb output (with and without selected file):

(lldb) process launch
Process 69657 launched: '/usr/local/bin/iaito' (arm64)
2022-02-06 15:31:39.345526+0100 iaito[69657:600121] QCommandLineParser: already having an option named "w"
2022-02-06 15:31:40.050198+0100 iaito[69657:600121] Plugins are loaded from "/Users/max/Library/Application Support/radareorg/iaito/plugins"
2022-02-06 15:31:40.050264+0100 iaito[69657:600121] Loaded 0 plugin(s).
2022-02-06 15:31:40.050280+0100 iaito[69657:600121] Plugins are loaded from "/Library/Application Support/radareorg/iaito/plugins"
2022-02-06 15:31:40.050515+0100 iaito[69657:600121] Plugins are loaded from "/usr/local/bin/plugins"
2022-02-06 15:31:40.361970+0100 iaito[69657:600121] [qt.qpa.fonts] Populating font family aliases took 107 ms. Replace uses of missing font family "Helvetica, Arial, Sans-serif" with one that exists to avoid this cost.
Process 69657 stopped
* thread #9, name = 'Thread (pooled)', stop reason = EXC_BAD_ACCESS (code=1, address=0x90)
    frame #0: 0x0000000100619144 libr_cons.dylib`r_cons_sleep_end(user=0x000060000291f800) at cons.c:500:9
   497 	}
   498
   499 	R_API void r_cons_sleep_end(void *user) {
-> 500 		if (I->cb_sleep_end) {
   501 			I->cb_sleep_end (I->user, user);
   502 		}
   503 	}
Target 0: (iaito) stopped.

Unfortunely, iaito is using a single core instance from multiple threads, which is conceptually wrong, so now, that r2 is thread safe, iaito fails hard by assuming globals are initialized and uses the mutexes incorrectly too.

I pushed some fixes in r2 and iaito, but its still not yet fully working (but at least is not crashing). But you will need to build r2 without threads to try it out.

radare2$ sys/install.sh --disable-threads

Thanks for the quick reply and I understand that as an open source project things might not always be working out right away. I actually just wanted to try iaito out, to see how different it is from command line r2 and got confused because I couldn't find an issue, so no worries

So I was able to run it once, trying to open decompiler crashed it though (maybe r2ghidra?). Now when I try to open it again (make run or in /Applicatons) I get:

rarun2 libpath=/usr/local/lib program=build/iaito.app/Contents/MacOS/iaito
QCommandLineParser: already having an option named "w"
make: *** [run] Killed: 9

Strange thing is when I run it via lldb it crashes but still opens. And decompiler doesn't crash, but it loads forever

Did you git pull r2 and iaito and compiled r2 without threads? Otherwise if your purpose is to try it out i would recommend you to build r2-5.4 or 5.5 which didnt had thread safety magic yet

Yeah I pulled latest master branch from both and build as per your instruction. But I can try tomorrow again (and use your suggestion)

So tried it again and it doesn't open at all now and I just get make: *** [run] Killed: 9 in terminal.
Also I noticed that it's actually radare2 crashing now, more specifically the r2 binary

Ignore the last edit after restarting it worked. With the master branch decompiler still doesn't work though, but version 5.5 was looking fine, thanks for your help!

499 R_API void r_cons_sleep_end(void *user) {

Same issue on Fedora Linux with the r2 5.6.0 release .
Workaround with disabling threads works there as well
(radare2-5a7ffe4c0a71794fbb0b945d52065c7c11d1eec2 + iaito-28a1099603b3fa671bfbb226025d1a8c45558471,
meson ... -Dwant_threads=false )

Yep that's expected because Iaito is far from thread safe.

I dont think i can cook the needed apis before 5.7. I will update and release a new iaito when this is ready.

Seems that -Dwant_threads=false is gone from radare2 5.6.4 ... did anything change regarding compiling iaito with recent radare2 versions?

Sorry - my fault - it is working with radare2 5.6.4

Is the disasm issue (only showing instruction without arguments) still happening?

Yes unfortunately issue with not showing the arguments is still there.
image

And BTW there are some comming issues with the recent update of kf5 from 5.90 to 5.91 kf5-syntax-highlighting-devel stopped advertising include dir /usr/include/KF5
https://bugzilla.redhat.com/show_bug.cgi?id=2059619

The missing operands is fixed in master. What should we do to fix the kf5 issue?

OK operands fixed in master.

For #70 KF5 5.91 I am adding include for /usr/include/KF5 when compiling with syntax highlighting. Probably not a best solution, but works for now.

I believe this incident can be closed - please @Maxung can you confirm for the MacOS side?

Currently getting this, I'll try tomorrow on my other Mac to see if it's environment problem on my side:

Kyouko:~/iaito (master %) % make   
mkdir -p build
cd build && /opt/homebrew/bin/qmake ../src/Iaito.pro 
Info: creating stash file /Users/max/iaito/build/.qmake.stash
Project ERROR: failed to parse default search paths from compiler output
make: *** [build] Error 3

Ok tested on a pretty fresh system (macOS 12.2) and building + running just fine. Only thing is that the decompiler (pdc) is still loading forever, but I think that might be a separate issue