Open jnhols opened 1 year ago
Notes on the problem itself:
==> Some times uninitialized should be in the group of out-nodes (or completely purges from the dependency graph).
Smaller Code which probably represents the same problem:
int f1(int argc){
char* g_1 = "dump global str1";
char* g_2 = "dump global str2";
char* ptr;
if(argc){
g_1 = ptr;
}else{
g_2 = ptr;
}
return g_1;
}
Output of Decompiler:
void * f1(int arg1) {
return "dump global str1";
}
The stage incorrectly merges var_10#0, var_20#3 and "dump global str1" into "dump global str1", completely destroying the correct control flow. Again var_10#0 (char* ptr) is not in the group of out-nodes, which would probably fix the problem.
Binary for testing: a.out.zip
Note: All three functions in the binary have the same problem, but main behaves differently because of the return type. (Maybe other issue)
Many more binaries have the problem. I will not upload them all, but the log which shows what function has a problem.
All binaries are part of the GNU core utils ValueError: At least.log
Updated log for Windows bins: ValueError: At least two varia.log
I guess I found the problem, at least for some of the samples, I did not check all :wink:
We build the identity graph and then remove edges such that each connected component can be an identity afterward. What we miss is the following case: We have the following phi-functions:
var_70#7 = phi(var_70#0, var_40_1#3)
var_70#3 = phi(var_70#0, rcx_12#11)
var_70#4 = phi(var_70#0, r9_10#8)
The variable var_70#0
is undefined, and the other variable in each phi-function is a value which can not be identified with is defining value.
Now, it should be possible to identify each phi-function by itself, but not all together. But since they are in one connected component, we try to identify them all together.
In this case, it could be a good to identify var_70#7
and var_40_1#3
, var_70#3
and rcx_12#11
, as well as var_70#4
and r9_10#8
, and to remove the three phi-functions.cfg:
identity graph, where we try to identify each connected component:
Issue #388 only solves some of the problems mentioned in this Issue. It does not address https://github.com/fkie-cad/dewolf/issues/135#issuecomment-1413464989
What happened?
The decompiler crashes with a ValueError in identity_elimination.
How to reproduce?
Decompile main in the following sample.
seq.zip
Affected Binary Ninja Version(s)
3.2.3814