Skip to content

Commit 7cc4c6c

Browse files
authored
redirects all the channels when radare2 is spawned (#1205)
We're experience random failures on the arm-symexec-crc32 test that appears like a race condition between bap and the Tcl's expect framework. It looks like that while the symbolic executor is able to hack the program and emits the 'access granted' token, the expect command is either not seeing it or is not able to stop bap. We don't have strong evidences that it has anything to do with radare2, but our internal testing and bisecting shows that the issues likelihood raised with the #1195 PR merged and that if we will redirect all channels, we have much more consistent behavior of the test. Given this, we still have no explanation, why is this happening and why only the arm test is showing this problem. Therefore, this PR may fix nothing. It is still, however, a good idea to redirect the input channel, as radare2, being an interactive program, may play tricks with the stdin channel.
1 parent c8250d3 commit 7cc4c6c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

plugins/radare2/radare2_main.ml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,17 @@ let parse =
4949
to_string @@ member "type" x
5050

5151
let extract_symbols file =
52-
let cmd = sprintf "radare2 -2 -q -cisj %s" file in
53-
let input = Unix.open_process_in cmd in
52+
let cmd = sprintf "radare2 -2 -q -c isj %s" file in
53+
let env = Unix.environment () in
54+
let input,output,err = Unix.open_process_full cmd env in
5455
let out = try parse@@Yojson.Safe.from_channel input with
5556
| exn ->
5657
warning "failed to extract symbols: %s" (Exn.to_string exn);
5758
[] in
58-
match Unix.close_process_in input with
59-
| Unix.WEXITED 0 -> out
59+
match Unix.close_process_full (input,output,err) with
60+
| Unix.WEXITED 0 ->
61+
info "radare2 invocation finished successfully";
62+
out
6063
| WEXITED n ->
6164
warning "radare2 failed with the exit code %d" n;
6265
out

0 commit comments

Comments
 (0)